This is my code for Automatic number plate recognition, for some reason it is recognizing plates in some image and not recognizing in other similar image, can some1 help me know why ? I'll attach the two images here ( first working, seconf not workin

1 view (last 30 days)
A = imread('A.png'); B = imread('B.png'); C = imread('C.png'); D = imread('D.png'); E = imread('E.png'); F = imread('F.png'); G = imread('G.png'); J = imread('j.png'); K = imread('K.png'); S = imread('S.png'); T = imread('T.png'); U = imread('U.png'); V = imread('V.png'); W = imread('W.png'); zero = imread('0.png'); one = imread('1.png'); two = imread('2.png'); three = imread('3.png'); four = imread('4.png'); five = imread('5.png'); six = imread('6.png'); seven = imread('7.png'); eight = imread('8.png'); nine = imread('9.png');
array = {A,B,C,D,E,F,G,J,K,S,T,U,V,W,zero,one,two,three,four,five,six,seven,eight,nine};
arrayAlph = {'A','B','C','D','E','F','G','J','K','S','T','U','V','W','0','1','2','3','4','5','6','7','8','9'};
img = imread('num6.jpg'); %Read image from graphics file
figure, imshow(img); %Create texture image
img1 = rgb2gray(img);
img3 = imcrop(img1,[680 1400 1400 1000]);
%figure; imshow(img3);
%[566.5 1335.5 1764 1356]
img4 =im2bw(img3);
figure, imshow(img4);
stats = regionprops(img4); %segmentation
S = ' ';
for index=1:length(stats)
if stats(index).Area > 200 && stats(index).BoundingBox(3)*stats(index).BoundingBox(4) < 30000
x = ceil(stats(index).BoundingBox(1));
y= ceil(stats(index).BoundingBox(2));
widthX = floor(stats(index).BoundingBox(3)-1);
widthY = floor(stats(index).BoundingBox(4)-1);
subimage(index) = {img4(y:y+widthY,x:x+widthX,:)};
%createsize variables to extracct out the noise which is smaller than
%template size
[m,n]=size(subimage{index});
max = 0; %varaible max to store the maximum value of correlation coeffecient
%figure;imshow( subimage{index});
if(m >= 119 && n >= 30) % extract out the noise
img5 = imresize((subimage{index}),[130,90]); %store the segmented part for further analysis
segment =im2bw(img5,0.4);
figure; imshow(segment);
for i = 1:length(array) % loop through the set of refference images and calculate the correlation coefficient
Img = imcrop(array{i} ,[83 31 89 129]);
Img = im2bw(Img,0.4);
R = corr2(segment,Img);
if(R>max) % find out the highest value of correlation coefficient
max=R;
position=i;
end
end
S = strcat(S,arrayAlph{position});
end
end
end
S

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!