该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
I=imread('C:\Users\Administrator\Desktop\123.jpg');
figure(1)
subplot(3,2,1),imshow(I), title('原始图像');
I1=rgb2gray(I);
subplot(3,2,2),imshow(I1),title('灰度图像');
I2=edge(I1,'roberts',0.09,'both');
subplot(3,2,3),imshow(I2),title('边缘检测后图像');
se=[1;1;1];
I3=imerode(I2,se);
subplot(3,2,4),imshow(I3),title('腐蚀后边缘图像');
se=strel('rectangle',[25,25]);
I4=imclose(I3,se);
subplot(3,2,5),imshow(I4),title('填充后图像');
I5=bwareaopen(I4,2000);
subplot(3,2,6),imshow(I5),title('形态滤波后图像');
[y,x,z]=size(I5);
I6=double(I5);
Y1=zeros(y,1);
for i=1:y
for j=1:x
if(I6(i,j,1)==1)
Y1(i,1)= Y1(i,1)+1;
end
end
end
[temp MaxY]=max(Y1);
figure(2)
subplot(3,2,1),plot(0:y-1,Y1),title('行方向像素点灰度值累计和'),xlabel('行值'),ylabel('像素');
PY1=MaxY;
while((Y1(PY1,1)>=50)&&(PY1>1))
PY1=PY1-1;
End
PY2=MaxY;
while((Y1(PY2,1)>=50)&&(PY2
PY2=PY2+1;
End
IY=I(PY1:PY2,:,:);
X1=zeros(1,x);
for j=1:x
for i=PY1:PY2
if(I6(i,j,1)==1)
X1(1,j)= X1(1,j)+1;
End
End
End
subplot(3,2,2),plot(0:x-1,X1),title('列方向像素点灰度值累计和'),xlabel('列值'),ylabel('像数');
PX1=1;
while((X1(1,PX1)<3)&&(PX1
PX1=PX1+1;
End
PX2=x;
while((X1(1,PX2)<3)&&(PX2>PX1))
PX2=PX2-1;
End
PX1=PX1-1;
PX2=PX2+1;
dw=I(PY1:PY2,PX1:PX2,:);
subplot(3,2,3),imshow(dw),title('定位剪切后的彩色车牌图像')
if isrgb(dw)
I1 = rgb2gray(dw);
Else
I1=dw;
End
g_max=double(max(max(I1)));
g_min=double(min(min(I1)));
T=round(g_max-(g_max-g_min)/3);
[m,n]=size(I1);
%h=graythresh(I1);
I1=im2bw(I1,T/256);
subplot(3,2,4);
imshow(I1),title('二值化车牌图像');
I2=bwareaopen(I1,20);
subplot(3,2,5);
imshow(I2),title('形态学滤波后的二值化图像');