精选优质文档-倾情为你奉上 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.08figure(3),imshow(I2);title(robert算子边缘检测)se=1;1;1;I3=imerode(I2,se); %图像的腐蚀figure(4),imshow(I3);title(腐蚀后图像);se=strel(rectangle,40,40); %构造结构元素,以长方形构造一个seI4=imclose(I3,se); %对图像实现闭运算,闭运算也能平