失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > matlab提取车牌字符程序 如何用matlab提取和识别车牌数?

matlab提取车牌字符程序 如何用matlab提取和识别车牌数?

时间:2024-01-17 18:23:47

相关推荐

matlab提取车牌字符程序 如何用matlab提取和识别车牌数?

我想开发一个matlab程序,可以用模板匹配方法提取和识别车辆的车牌号.

这是我的代码:

function letters = PengenalanPlatMobil(citra)

%load NewTemplates

%global NewTemplates

citra=imresize(citra,[400 NaN]); % Resizing the image keeping aspect ratio same.

citra_bw=rgb2gray(citra); % Converting the RGB (color) image to gray (intensity).

citra_filt=medfilt2(citra_bw,[3 3]); % Median filtering to remove noise.

se=strel('disk',1);

citra_dilasi=imdilate(citra_filt,se); % Dilating the gray image with the structural element.

citra_eroding=imerode(citra_filt,se); % Eroding the gray image with structural element.

citra_edge_enhacement=imsubtract(citra_dilasi,citra_eroding); % Morphological Gradient for edges enhancement.

imshow(citra_edge_enhacement);

citra_edge_enhacement_double=mat2gray(double(citra_edge_enhacement)); % Converting the class to double.

citra_double_konv=conv2(citra_edge_enhacement_double,[1 1;1 1]); % Convolution of the double image f

citra_intens=imadjust(citra_double_konv,[0.5 0.7],[0 1],0.1); % Intensity scaling between the range 0 to 1.

citra_logic=logical(citra_intens); % Conversion of the class from double to binary.

% Eliminating the possible horizontal lines from the output image of regiongrow

% that could be edges of license plate.

citra_line_delete=imsubtract(citra_logic, (imerode(citra_logic,strel('line',50,0))));

% Filling all the regions of the image.

citra_fill=imfill(citra_line_delete,'holes');

% Thinning the image to ensure character isolation.

citra_thinning_eroding=imerode((bwmorph(citra_fill,'thin',1)),(strel('line',3,90)));

%Selecting all the regions that are of pixel area more than 100.

citra_final=bwareaopen(citra_thinning_eroding,125);

[labelled jml] = bwlabel(citra_final);

% Uncomment to make compitable with the previous versions of MATLAB®

% Two properties 'BoundingBox' and binary 'Image' corresponding to these

% Bounding boxes are acquired.

Iprops=regionprops(labelled,'BoundingBox','Image');

%%% OCR STEP

[letter{1:jml}]=deal([]);

[gambar{1:jml}]=deal([]);

for ii=1:jml

gambar= Iprops(ii).Image;

letter{ii}=readLetter(gambar);

% imshow(gambar);

%

end

end

但识别出的数字总是错误的,检测到的数量太多或有时太少.

怎么解决?

如果觉得《matlab提取车牌字符程序 如何用matlab提取和识别车牌数?》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。