matlab提取车牌字符程序,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

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

怎么解决?

这里是images和this one

最佳答案

我会将字符检测后的循环更改为[gambar{1:jml}]=deal([]);

for ii=1:jml

gambar{ii}= Iprops(ii).Image;

%letter{ii}=readLetter(gambar);

imshow(gambar{ii});

end

我想你现在想做的是

(1)在应用字符提取和ocr之前,提前选择roi。

(2)将OCR应用于整个图像中的所有字符,然后使用邻近规则或其他规则来识别车牌号。

编辑:

如果你在字符提取之后运行下面的循环,你可以知道“接近”是什么意思:

[xn yn]=size(citra); %

figure, hold on

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

for ii=1:jml

gambar{ii}= double(Iprops(ii).Image)*255;

bb=Iprops(ii).BoundingBox;

image([bb(1) bb(1)+bb(3)],[yn-bb(2) yn-bb(2)-bb(4)],gambar{ii});

end

这是边缘检测后的图像:

在字符提取之后(在运行上述循环之后):

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值