lab project
lab project
Project Report
Submitted By:
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.2 Preprocessing:
Convert the image to grayscale and apply noise reduction.
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.
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 ->');
subplot(3, 1, 3);
plot(horz);
title('Histogram after Filtering');
xlabel('Column Number ->');
ylabel('Difference ->');
subplot(3, 1, 2);
plot(vert);
title('Histogram after passing through Low Pass Filter');
xlabel('Row Number ->');
ylabel('Difference ->');
subplot(3, 1, 3);
plot(vert);
title('Histogram after Filtering');
xlabel('Row Number ->');
ylabel('Difference ->');
figure(7), imshow(I);
title('Filtered Image');
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
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;
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