function [d]=main(jpg) I=imread('car.jpg'); figure(1),imshow(I);title('原图'); I1=rgb2gray(I); %将真彩色图像转换为灰度图像 figure(2),subplot(1,2,1),imshow(I1);title(' 灰度图'); figure(2),subplot(1,2,2),imhist(I1);title('灰度图直方图'); I2=edge(I1,'robert',0.08,'both'); %高斯滤波器,方差为0.08 figure(3),imshow(I2);title('robert算子边缘检测') se=[1;1;1]; I3=imerode(I2,se); %图像的腐蚀 figure(4),imshow(I3);title('腐蚀后图像'); se=strel('rectangle',[40,40]); %构造结构元素,以长方形构造一个se I4=imclose(I3,se); %对图像实现闭运算,闭运算也能平滑图像的轮廓,但与开运算相反,它一般融合窄的缺口和细长的弯口,去掉小洞,填补轮廓上的缝隙。 figure(5),imshow(I4);title('平滑图像的轮廓'); I5=bwareaopen(I4,2000); %从二进制图像中移除所有少于p像素的连接的组件(对象),产生另一个二进制图像 figure(6),imshow(I5);title(' 从对象中移除小对象'); [y,x,z]=size(I5); %返回I5各维的尺寸,并存储在变量y、x、z中 myI=double(I5); %换成双精度数值 %begin横向扫描 tic %计算tic与toc之间程序的运行时间 Blue_y=zeros(y,1); %产生y*1的全0矩阵 for i=1:y for j=1:x if(myI(i,j,1)==1) %如果myI(i,j,1)即myI图像中坐标为(i,j)的点为蓝色 %则Blue_y的相应行的元素white_y(i,1)值加1 Blue_y(i,1)= Blue_y(i,1)+1;%蓝色像素点统计 end end end [temp MaxY]=max(Blue_y);%temp为向量white_y的元素中的最大值,MaxY为该值的索引( 在向量中的位置) PY1=MaxY; while ((Blue_y(PY1,1)>=120)&&(PY1>1)) PY1=PY1-1; end PY2=MaxY; while ((Blue_y(PY2,1)>=40)&&(PY2PX1)) PX2=PX2-1; end %end纵向扫描 PX1=PX1-2;%对车牌区域的校正 PX2=PX2+2; dw=I(PY1:PY2,:,:); t=toc; figure(7),subplot(1,2,1),imshow(IY),title('行方向合理区域'); figure(7),subplot(...