0% found this document useful (0 votes)
3 views

lab project

The project report details the development of a MATLAB-based system for detecting and recognizing vehicle license plates using digital image processing techniques. It outlines the methodology, including image acquisition, preprocessing, edge detection, and OCR application, to automate vehicle identification for improved efficiency and accuracy. Future work includes enhancing the system for real-time processing and better handling of non-standard license plates.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

lab project

The project report details the development of a MATLAB-based system for detecting and recognizing vehicle license plates using digital image processing techniques. It outlines the methodology, including image acquisition, preprocessing, edge detection, and OCR application, to automate vehicle identification for improved efficiency and accuracy. Future work includes enhancing the system for real-time processing and better handling of non-standard license plates.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Course: CS-406 Digital Image Processing

Project Report

Submitted By:

Muhammad Jahangir (21-CS-089)

Basit Ali (21-CS-104)

Muhammad Alrayan (21-CS-107)

Section B

Submitted To:
Ms. Syeda Aimal Fatima
Department of Computer Science HITEC University
Taxila
Abstract
This project implements a MATLAB-based system for detecting and recognizing vehicle license
plates using digital image processing techniques. The system processes an image to locate the
license plate and extracts its alphanumeric content using Optical Character Recognition (OCR).
This document outlines the background, problem statement, methodology, workflow, scope, and
results of the project.

Table of Contents
Abstract ..................................................................................................................................................................... 2
1. Introduction ................................................................................................................................................ 3
2. Background ................................................................................................................................................. 3
3. Problem Statement .................................................................................................................................. 3
4. Objectives ..................................................................................................................................................... 3
5. Scope .............................................................................................................................................................. 3
6. Workflow...................................................................................................................................................... 4
6.1 Image Acquisition: .............................................................................................................................. 4
6.2 Preprocessing: ...................................................................................................................................... 4
6.3 Edge Detection: .................................................................................................................................... 4
6.4 Histogram Filtering: ........................................................................................................................... 4
6.5 ROI Extraction: ..................................................................................................................................... 4
6.6 OCR Application:.................................................................................................................................. 4
6.7 Display Results: .................................................................................................................................... 4
7. Methodology ............................................................................................................................................... 4
7.1 Image Acquisition: .............................................................................................................................. 4
7.2 Preprocessing: ...................................................................................................................................... 4
7.3 Edge Detection: .................................................................................................................................... 4
7.4 Histogram Filtering: ........................................................................................................................... 4
7.5 ROI Extraction: ..................................................................................................................................... 4
7.6 OCR: ........................................................................................................................................................... 4
8. Applications ................................................................................................................................................ 5
9. Future Work................................................................................................................................................ 6
10. Code ................................................................................................................................................................ 6
11. Result .......................................................................................................................................................... 11
12. Conclusion ................................................................................................................................................ 11
13. References ................................................................................................................................................ 11
1. Introduction
In modern times, the automation of vehicle identification systems has become a crucial need for
efficient management and security. Manual identification of license plates is time-consuming and
prone to errors, necessitating the development of automated systems. License Plate Recognition
(LPR) is a key technology used in traffic management, parking systems, and law enforcement.
This project leverages digital image processing techniques to develop a MATLAB-based
solution for license plate detection and recognition.

2. Background
With the rapid growth in vehicle ownership, managing traffic, enforcing laws, and maintaining
security has become challenging. Automated License Plate Recognition (ALPR) systems help
address these challenges by providing accurate and efficient vehicle identification. The primary
goal is to design a system capable of detecting license plates from vehicle images under various
conditions and extracting the alphanumeric content for further processing.

3. Problem Statement
Manual methods for vehicle identification are labor-intensive, error-prone, and inefficient,
particularly in scenarios involving large volumes of vehicles. Challenges such as noise, varying
lighting conditions, and plate orientations make automated license plate recognition a complex
task. This project aims to develop a robust and efficient MATLAB-based system to
automatically detect and recognize license plates from vehicle images, addressing these
challenges.

4. Objectives
• To implement a MATLAB-based system for license plate detection and recognition.
• To preprocess images for noise reduction and enhance edges for better detection.
• To develop a methodology for extracting the region of interest (ROI) containing the license
plate.
• To apply OCR for accurate text recognition of license plates.

5. Scope
The scope of this project includes:
• Processing static vehicle images (no real-time video processing).
• Detecting and recognizing standard license plates with clear alphanumeric characters.
• Handling moderate noise and lighting variations in images.
• Providing a scalable solution that can be integrated with larger systems such as traffic
management or parking systems.
6. Workflow

6.1 Image Acquisition:


Load a static image of a vehicle containing a license plate.

6.2 Preprocessing:
Convert the image to grayscale and apply noise reduction.

6.3 Edge Detection:


Calculate intensity differences and generate histograms.

6.4 Histogram Filtering:


Apply dynamic thresholding to identify potential license plate regions.

6.5 ROI Extraction:


Segment the image to isolate the most probable license plate region.

6.6 OCR Application:


Extract text using MATLAB’s OCR function.

6.7 Display Results:


Visualize outputs including the recognized license plate text.

7. Methodology
7.1 Image Acquisition:
The input image is read into MATLAB.

7.2 Preprocessing:
Grayscale conversion and morphological operations are applied.
7.3 Edge Detection:
Horizontal and vertical edge differences are computed.

7.4 Histogram Filtering:


Smooth histograms and apply thresholds.

7.5 ROI Extraction:


Identify and refine the license plate region.

7.6 OCR: Extract alphanumeric text using MATLAB's OCR functionality.


8. Applications
• Traffic law enforcement.
• Automated toll systems.
• Parking management systems.
• Vehicle tracking in secured areas.
9. Future Work
• Extend the system to process real-time video feeds.
• Enhance the algorithm to handle non-standard license plates.
• Improve robustness to extreme conditions.
• Integrate machine learning for higher accuracy.

10.Code
clc;
clear all; % Delete all variables.
close all; % Close all figure windows.
imtool close all; % Close all figure windows created by imtool.
workspace;
% Taking the Image as Input
I = imread('CAR1.jpg');
figure(1);
imshow(I);
title('Original Image');
% Extracting the Y component from the image (Converting to Grayscale)
Igray = rgb2gray(I);
[rows, cols] = size(Igray);
%% Dilate and Erode operations to remove noise
Idilate = Igray;
for i = 1:rows
for j = 2:cols-1
temp = max(Igray(i, j-1), Igray(i, j));
Idilate(i, j) = max(temp, Igray(i, j+1));
end
end
I = Idilate;
figure(2);
imshow(Igray);
title('Grayscale Image');
figure(3);
imshow(Idilate);
title('Dilated Image');
figure(4);
imshow(I);
title('Processed Image');
difference = 0;
sum = 0;
total_sum = 0;
difference = uint32(difference);
% Processing edges in Horizontal direction
disp('Processing Edges Horizontally...');
max_horz = 0;
maximum = 0;
for i = 2:cols
sum = 0;
for j = 2:rows
if (I(j, i) > I(j-1, i))
difference = uint32(I(j, i) - I(j-1, i));
else
difference = uint32(I(j-1, i) - I(j, i));
end
if (difference > 20)
sum = sum + difference;
end
end
horz1(i) = sum;
% Finding Peak Value
if (sum > maximum)
max_horz = i;
maximum = sum;
end
total_sum = total_sum + sum;
end
average = total_sum / cols;
figure(5);
% Plotting the Histogram
subplot(3, 1, 1);
plot(horz1);
title('Horizontal Edge Processing Histogram');
xlabel('Column Number ->');
ylabel('Difference ->');
% Smoothen the Horizontal Histogram by Low Pass Filtering
sum = 0;
horz = horz1;
for i = 21:(cols-21)
sum = 0;
for j = (i-20):(i+20)
sum = sum + horz1(j);
end
horz(i) = sum / 41;
end
subplot(3, 1, 2);
plot(horz);
title('Histogram after passing through Low Pass Filter');
xlabel('Column Number ->');
ylabel('Difference ->');

% Filter out Horizontal Histogram Values through Dynamic Thresholding


disp('Filter out Horizontal Histogram');
for i = 1:cols
if (horz(i) < average)
horz(i) = 0;
for j = 1:rows
I(j, i) = 0;
end
end
end

subplot(3, 1, 3);
plot(horz);
title('Histogram after Filtering');
xlabel('Column Number ->');
ylabel('Difference ->');

%% Processing edges in Vertical Direction


difference = 0;
total_sum = 0;
difference = uint32(difference);
disp('Processing Edges Vertically...');
maximum = 0;
max_vert = 0;
for i = 2:rows
sum = 0;
for j = 2:cols
if (I(i, j) > I(i, j-1))
difference = uint32(I(i, j) - I(i, j-1));
else
difference = uint32(I(i, j-1) - I(i, j));
end
if (difference > 20)
sum = sum + difference;
end
end
vert1(i) = sum;
% Find Peak Value
if (sum > maximum)
max_vert = i;
maximum = sum;
end
total_sum = total_sum + sum;
end

average = total_sum / rows;


figure(6)
subplot(3, 1, 1);
plot(vert1);
title('Vertical Edge Processing Histogram');
xlabel('Row Number ->');
ylabel('Difference ->');

%% Smoothen the Vertical Histogram through Low Pass Filtering


disp('Passing Vertical Histogram through Low Pass Filter');
sum = 0;
vert = vert1;
for i = 21:(rows-21)
sum = 0;
for j = (i-20):(i+20)
sum = sum + vert1(j);
end
vert(i) = sum / 41;
end

subplot(3, 1, 2);
plot(vert);
title('Histogram after passing through Low Pass Filter');
xlabel('Row Number ->');
ylabel('Difference ->');

%% Filter out Vertical Histogram Values through Dynamic Thresholding


disp('Filter out Vertical Histogram...');
for i = 1:rows
if (vert(i) < average)
vert(i) = 0;
for j = 1:cols
I(i, j) = 0;
end
end
end

subplot(3, 1, 3);
plot(vert);
title('Histogram after Filtering');
xlabel('Row Number ->');
ylabel('Difference ->');

figure(7), imshow(I);
title('Filtered Image');

%% Find Probable segments for Number Plate


j = 1;
for i = 2:cols-2
if (horz(i) ~= 0 && horz(i-1) == 0 && horz(i+1) == 0)
column(j) = i;
column(j+1) = i;
j = j + 2;
elseif ((horz(i) ~= 0 && horz(i-1) == 0) || (horz(i) ~= 0 && horz(i+1) == 0))
column(j) = i;
j = j+1;
end
end

j = 1;
for i = 2:rows-2
if (vert(i) ~= 0 && vert(i-1) == 0 && vert(i+1) == 0)
row(j) = i;
row(j+1) = i;
j = j + 2;
elseif ((vert(i) ~= 0 && vert(i-1) == 0) || (vert(i) ~= 0 && vert(i+1) == 0))
row(j) = i;
j = j+1;
end
end

[temp, column_size] = size(column);


if (mod(column_size, 2))
column(column_size+1) = cols;
end

[temp, row_size] = size(row);


if (mod(row_size, 2))
row(row_size+1) = rows;
end

%% Region of Interest Extraction


% Checking each probable candidate
for i = 1:2:row_size
for j = 1:2:column_size
% If it is not the most probable region delete from image
if (~((max_horz >= column(j) && max_horz <= column(j+1)) && (max_vert >= row(i) &&
max_vert <= row(i+1))))
% To display output to user
for m = row(i):row(i+1)
for n = column(j):column(j+1)
I(m, n) = 0;
end
end
end
end
end

figure(8), imshow(I);
title('Final Segmented Plate');

%% OCR Functionality
% Use OCR to read the text from the extracted plate region
ocrResults = ocr(I, 'TextLayout', 'Block');
recognizedText = ocrResults.Text;

disp('Recognized License Plate:');


disp(strtrim(recognizedText));

% Display OCR results on the final image


figure(9);
imshow(I);
title(['Detected Plate: ', strtrim(recognizedText)]);
11. Result

12.Conclusion
This project successfully implemented a license plate detection and recognition system using MATLAB.
By combining morphological operations, edge detection, and OCR, the system effectively identified and
read license plates from images. Future enhancements can focus on real-time capabilities and improved
robustness.

13. References
• MATLAB Documentation: https://www.mathworks.com/help
• Digital Image Processing Textbooks and Research Papers
• Online tutorials and guides for OCR in MATLAB

You might also like