数字图像处理综合实验报告车牌识别技术(LPR)=imread('');figure;subplot(2,2,1);imshow(I);title('原图');I1=rgb2gray(I);%图象灰度化subplot(2,2,2);imshow(I1);title('灰度化图');m2=medfilt2(I1,[5,5]);subplot(2,2,3);imshow(m2);title('中值滤波');w2=wiener2(I1,[5,5]);%维纳滤波subplot(2,2,4);imshow(w2);title('维纳滤波');=double(max(max(I1)));fmin1=double(min(min(I1)));level=(fmax1-(fmax1-fmin1)/3)/255;bw2=im2bw(I1,level);bw22=double(bw2);figure,imshow(bw22),title('图像二值化');=edge(bw22,'log');figure;subplot(2,2,1);imshow(bw2);title('Log算子边缘检测');%图象边缘检测bg1=imclose(lubo,strel('rectangle',[1,33]));subplot(2,2,2),imshow(bg1);title('图像闭运算[1,33]');bg3=imopen(bg1,strel('rectangle',[1,33]));subplot(2,2,3),imshow(bg3);title('图像开运算[1,33]');bg2=imopen(bg3,strel('rectangle',[12,1]));subplot(2,2,4),imshow(bg2);title('图像开[15,1]');[L,num]=bwlabel(bg2,8);%标注二进制图像中已连接的部分%Feastats=imfeature(L,'basic');%计算图像区域的特征尺寸%Area=[];%区域面积%BoundingBox=[];%[xywidthheight]车牌的框架大小%RGB=label2rgb(L,'spring','k','shuffle');%标志图像向RGB图像转换figure,imshow(L);title('图像标记');%=bwareaopen(L,1000);%去除聚团灰度值小于2000的部分figure,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;end end end[tempMaxY]=max(Y1);figure();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<y))PY2=PY2+1;endIY=I(PY1:PY2,:,:);X1=zeros(1,x);forj=1:xfori=PY1:PY2if(I6(i,j,1)==1)X1(1,j)=X1(1,j)+1; end endendsubplot(3,2,2),plot(0:x-1,X1),title('列方向像素点灰度值累计和'),xlabel('列值'),ylabel('像数');PX1=1;while((X1(1,PX1)<3)&&(PX1<x))PX1=PX1+1;end PX2=x;while((X1(1,PX2)<3)&&(PX2>PX1))PX2=PX2-1;endPX1=PX1-1;PX2=PX2+1;%分割出车牌图像%dw=I(PY1:PY2,PX1:PX2,:);subplot(3,2,3),imshow(dw),title('定位剪切后的彩色车牌图像')ifisrgb(dw)II1=rgb2gray(dw); %将RGB图像转化为灰度图像else II1=dw;endg_max=double(max(max(II1)));g_min=double(min(min(II1)));
车牌识别程序及说明 来自淘豆网m.daumloan.com转载请标明出处.