资源描述:
《matlab图像增强与平滑简单程序.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、图像增强与平滑直方图:I=imread('1.jpg');imshow(I);I=rgb2gray(I);%三维变成二维的图;figure,imhist(I);%显示灰度分布直方图均衡处理:I=imread('1.jpg');I=rgb2gray(I);J=histeq(I);Subplot(1,2,1),imshow(I);Subplot(1,2,2),imshow(J);figure,Subplot(1,2,1),imhist(I,64);Subplot(1,2,2),imhist(J,64);%这个参数是什么
2、意思???灰度变换:imadjust(I,[],[],);I=imread('1.jpg');I=rgb2gray(I);J=imadjust(I,[0.1,0.5],[]);Subplot(1,2,1),imshow(I);Subplot(1,2,2),imshow(J);figure,Subplot(1,2,1),imhist(I,64);Subplot(1,2,2),imhist(J,64);图像反转:I=imread('1.jpg');I=rgb2gray(I);J=imadjust(I,[0.1,0.9]
3、,[0.90.1]);Subplot(1,2,1),imshow(I);Subplot(1,2,2),imshow(J);figure,Subplot(1,2,1),imhist(I,64);Subplot(1,2,2),imhist(J,64);图像平滑噪声I=imread('1.jpg');I=rgb2gray(I);J=imnoise(I,'salt&pepper',0.02);H=ones(5,5)/25;I2=imfilter(J,H);%领域平均法去噪;Subplot(1,2,1),imshow(J);
4、Subplot(1,2,2),imshow(I2);高斯噪声J=imnoise(I,’gaussian’,0.02);%高斯噪声I=imread('1.jpg');I=rgb2gray(I);J=imnoise(I,'gaussian',0.02);H=ones(5,5)/25;I2=imfilter(J,H);%领域平均法去噪;Subplot(1,2,1),imshow(J);Subplot(1,2,2),imshow(I2);掩模大小对比I=imread('2.bmp');I=rgb2gray(I);J=imn
5、oise(I,'gaussian',0.02);H=ones(2,2)/25;H1=ones(5,5)/25;I1=imfilter(J,H1);%5*5领域平均法去噪I2=imfilter(J,H);%2*2领域平均法去噪Subplot(1,2,1),imshow(I1);Subplot(1,2,2),imshow(I2);中值滤波I=imread('2.bmp');I=rgb2gray(I);J=imnoise(I,'gaussian',0.02);H=ones(5,5)/25;I2=medfilt2(J,[5
6、,5]);Subplot(1,2,1),imshow(J);Subplot(1,2,2),imshow(I2);梯度法对图像锐化I=imread('2.bmp');I=rgb2gray(I);I=double(I);[IX,IY]=gradient(I);GM=sqrt(IX.*IX+IY.*IY);figure(1),imshow(GM,[]);拉普拉斯贝尔特拉米算子I=imread('2.bmp');I=rgb2gray(I);I=double(I);Subplot(1,2,1),imshow(I,[]);H=
7、[010,1-41,010];J=conv2(I,H,'same');figure(1),imshow(J,[]);图像色彩加强[rgb]=imread('3.jpg');rbgnew(:,:,1)=rgb(:,:,3);rbgnew(:,:,2)=rgb(:,:,1);rbgnew(:,:,3)=rgb(:,:,2);figure,imshow(rbgnew);图像分割边缘检测I=imread('2.bmp');I=rgb2gray(I);J=edge(I,’Roberts’,0.1);/%edge调用rober
8、ts,算子,,,阀值0.1figure(1),imshow(J,[]);阀值0.05;;;;;;;