- 1、本文档共4页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
[filename, pathname] = uigetfile({*.jpg, JPEG文件(*.jpg);*.bmp,BMP文件(*.bmp);});
if(filename == 0), return, end
global FILENAME %声明全局变量
FILENAME = [pathname filename];
I=imread(FILENAME);
imshow(I); %显示图像I
I1=rgb2gray(I);%RGB图转化为灰度图
figure,imshow(I1);
w1=medfilt2(I1);
figure,imshow(w1);
s1=histeq(w1,256);
figure,imshow(s1);
t1=imadjust(s1);
figure,imshow(t1);
I2=edge(t1,robert,0.15,both); %用ROBERT算子提取图像边缘
figure,imshow(I2);
se=[1;1;1];
I3=imerode(I2,se); %弱化二进制图像I2的边缘
figure,imshow(I3);%为定位车牌,将白色区域膨胀,腐蚀去无关的小物件,包括车牌字符(下面两句)
se=strel(rectangle,[25,20]); %用来腐蚀的形状为矩形,面积20*25
I4=imclose(I3,se);
figure,imshow(I4);
I5=bwareaopen(I4,2000); %去除图像中面积过小的,可以肯定不是车牌的区域。
figure,imshow(I5);
[y,x,z]=size(I5); %z=1。 y,x分别为I5图像的高和宽
myI=double(I5)
%myI=I5;
tic
%begin横向扫描
white_y=zeros(y,1); %white_y为y行1列的零矩阵
for i=1:y
for j=1:x
if(myI(i,j,1)==1)
%如果myI(i,j,1)即myI图像中坐标为(i,j)的点为白色
%则white_y的相应行的元素white_y(i,1)值加1
white_y(i,1)= white_y(i,1)+1;
end
end
end
[temp MaxY]=max(white_y); %temp为向量white_y的元素中的最大值,MaxY为该值的索引(在向量中的位置)
PY1=MaxY;
while ((white_y(PY1,1)=80)(PY11))
PY1=PY1-1;
end
PY2=MaxY;
while ((white_y(PY2,1)=80)(PY2y))
PY2=PY2+1;
end
IY=I(PY1:PY2,:,:); %IY为原始图像I中截取的纵坐标在PY1:PY2之间的部分
%end横向扫描
%begin纵向扫描
white_x=zeros(1,x);
for j=1:x
for i=PY1:PY2
if(myI(i,j,1)==1)
white_x(1,j)= white_x(1,j)+1;
end
end
end
PX1=1;
while ((white_x(1,PX1)3)(PX1x))
PX1=PX1+1;
end
PX2=x;
while ((white_x(1,PX2)3)(PX2PX1))
PX2=PX2-1;
end
%end纵向扫描
PX1=PX1-2;
PX2=PX2+2;
Plate=I(PY1:PY2,:);
t=toc
figure,plot(white_y);grid
figure,plot(white_x);grid
figure,imshow(IY);
figure,imshow(Plate);
% if isrgd(Plate);
Plate3=rgb2gray(Plate);
%else
% Plate2=Plate;
%end
plate4=medfilt2(Plate3);
plate5=histeq(plate4,256);
Plate2=imadjust(plate5);
g_max=double(max(ma
文档评论(0)