我正在从MATLAB中的车牌号检测数字和符号(残疾人)的项目。我已经创建了相同的模板。从盘子中检索数字,得到了各种结果。我主要关注的是正确读取数字和牌照。任何人都可以帮我吗?
%模板程序
desiredsize = [42 24];
files = {'1', '2', '3', '4', '5', '0', 'sign'};
NewTemplates1 = cell(size(files));
for fileidx = 1:numel(files)
img = imread([files{fileidx}, '.png']);
img= rgb2gray(img);
img = imresize(img, desiredsize);
NewTemplates1{fileidx} = img;
end
%号提取程序
clc;
clear all;
load NewTemplates1;
word=[ ];
img=imread('2222.jpg');
figure,imshow(img);
[~,cc]=size(img);
picture=imresize(img,[300 500]);
if size(picture,3)==3
picture=rgb2gray(picture); %grey values are btwn 0 to 1 or 0 to 255
end
threshold = graythresh(picture); %greythresh gives the threshold value of greyscale image
picture =~im2bw(picture,threshold); %black nd white values are 0 or 1 and values greater thn threshold=1,rest=0 and invert white and black ie 1 to 0 and 0 to 1
picture = bwareaopen(picture,30); % those things that have less than 30 pixels are removed
if cc>2000
picture1=bwareaopen(picture,3500); %those things that have less than 3500 pixels are removed ie excluding nmbr plate
else
picture1=bwareaopen(picture,3000); %those things that have less than 3000 pixels are removed ie excluding nmbr plate
end
figure,imshow(picture1);
picture2=picture-picture1; %only number plate is left
picture2=bwareaopen(picture2,50); %only text is there in the nmbr plate
figure,imshow(picture2);
title('plate extracted');
[L,Ne]=bwlabel(picture2,8);
%% Measure properties of image regions
propied=regionprops(L,'BoundingBox');
hold on
%% Plot Bounding Box
for n=1:size(propied,1)
rectangle('Position',propied(n).BoundingBox,'EdgeColor','g','LineWidth',2)
end
hold off
pause (1)
% Compute the number of letters in template file
num_letras=size(NewTemplates1,2);
%% Objects extraction
figure
for n=1:Ne
[r,c] = find(L==n);
n1=picture2(min(r):max(r),min(c):max(c));
img_r=imresize(n1,[42 24]);
letter=readLetter1(img_r);
% Letter concatenation
word=[word letter];
fid = fopen('noPlate.txt', 'wt'); % This portion of code writes the number plate
fprintf(fid,'%s\n',word); % to the text file, if executed a notepad file with the
fclose(fid); % name noPlate.txt will be open with the number plate written.
winopen('noPlate.txt')
% imshow(~n1);
pause(0.5);
end