-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlate_detection.m
More file actions
40 lines (33 loc) · 1.16 KB
/
Plate_detection.m
File metadata and controls
40 lines (33 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
close all;
clear all;
im = imread('Number Plate Images/image1.png');
imgray = rgb2gray(im);
imbin = imbinarize(imgray);
im = edge(imgray, 'prewitt');
%Below steps are to find location of number plate
Iprops=regionprops(im,'BoundingBox','Area', 'Image');
area = Iprops.Area;
count = numel(Iprops);
maxa= area;
boundingBox = Iprops.BoundingBox;
for i=1:count
if maxa<Iprops(i).Area
maxa=Iprops(i).Area;
boundingBox=Iprops(i).BoundingBox;
end
end
im = imcrop(imbin, boundingBox);%crop the number plate area
im = bwareaopen(~im, 500); %remove some object if it width is too long or too small than 500
[h, w] = size(im);%get width
imshow(im);
Iprops=regionprops(im,'BoundingBox','Area', 'Image'); %read letter
count = numel(Iprops);
noPlate=[]; % Initializing the variable of number plate string.
for i=1:count
ow = length(Iprops(i).Image(1,:));
oh = length(Iprops(i).Image(:,1));
if ow<(h/2) & oh>(h/3)
letter=Letter_detection(Iprops(i).Image); % Reading the letter corresponding the binary image 'N'.
noPlate=[noPlate letter] % Appending every subsequent character in noPlate variable.
end
end