基于Matlab的车牌定位与分割经典算法I=imread('car
jpg');%读取图像figure();subplot(3,2,1),imshow(I),title('原始图像');I1=rgb2gray(I);%转化为灰度图像subplot(3,2,2),imshow(I1),title('灰度图像');I2=edge(I1,'robert',0
09,'both');%采用robert算子进行边缘检测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);%去除聚团灰度值小于2000的部分subplot(3,2,6),imshow(I5),title('形态滤波后图像');[y,x,z]=size(I5);I6=double(I5);Y1=zeros(y,1);fori=1:yforj=1:xif(I6(i,j,1)==1)Y1(i,1)=Y1(i,1)+1;endendend[tempMaxY]=max(Y1);figure();subplot(3,2,1),plot(0:y-1,Y1),title('行方向像素