Hie guys, when i run matlab code, it displays characters from a vehicles number plate but it is saving only the last letter of the number plate in a text document. the number plate has seven characters( 3 letters and four numbers)

1 回表示 (過去 30 日間)
the code is as follows
clc
close all;
clear;
load imgfildata;
[file,path]=uigetfile({'*.jpg;*.bmp;*.png;*.tif'},'Choose an image');
s=[path,file];
picture=imread(s);
[~,cc]=size(picture);
picture=imresize(picture,[300 500]);
if size(picture,3)==3
picture=rgb2gray(picture);
end
threshold = graythresh(picture);
picture =~im2bw(picture,threshold);
picture = bwareaopen(picture,30);
imshow(picture)
if cc>2000
picture1=bwareaopen(picture,3500);
else
picture1=bwareaopen(picture,3000);
end
figure,imshow(picture1)
picture2=picture-picture1;
figure,imshow(picture2)
picture2=bwareaopen(picture2,200);
figure,imshow(picture2)
[L,Ne]=bwlabel(picture2);
propied=regionprops(L,'BoundingBox');
hold on
pause(1)
for n=1:size(propied,1)
rectangle('Position',propied(n).BoundingBox,'EdgeColor','g','LineWidth',2)
end
hold off
figure
final_output=[];
t=[];
for n=1:Ne
[r,c] = find(L==n);
n1=picture(min(r):max(r),min(c):max(c));
n1=imresize(n1,[42,24]);
imshow(n1)
pause(0.2)
x=[ ];
end
totalLetters=size(imgfile,2);
for k=1:totalLetters
y=corr2(imgfile{1,k},n1);
x=[x y];
end
t=[t max(x)];
if max(x)>.45
z=find(x==max(x));
out=cell2mat(imgfile(2,z));
%final_output= [final_output out];
fid = fopen('Log.txt', 'at');
fprintf(fid,'%s\n\n',date,out);
fclose(fid);
winopen('Log.txt')
else
fid = fopen ('failed.txt','wt');
fprintf(fid,'%s\n','ATTENTION!: EXTRACTION COULD NOT BE COMPLETED.\n');
fprintf(fid,'The characters on number plate might not be clear.\n');
fclose(fid);
winopen('failed.txt')
fprintf('ATTENTION!: EXTRACTION COULD NOT BE COMPLETED.\n');
fprintf('The characters on number plate might not be clear.\n');
end

回答 (1 件)

karthikeyan chandrasekar
karthikeyan chandrasekar 2019 年 8 月 16 日
Try changing the sensitivity of "bwareaopen" function in the line -> picture = bwareaopen(picture,30);
instead of 30 try greater values or less untill required image obtained.

カテゴリ

Help Center および File ExchangeAgriculture についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by