matlab对图片加入噪声.docx

上传人:b****3 文档编号:27565332 上传时间:2023-07-02 格式:DOCX 页数:11 大小:956.79KB
下载 相关 举报
matlab对图片加入噪声.docx_第1页
第1页 / 共11页
matlab对图片加入噪声.docx_第2页
第2页 / 共11页
matlab对图片加入噪声.docx_第3页
第3页 / 共11页
matlab对图片加入噪声.docx_第4页
第4页 / 共11页
matlab对图片加入噪声.docx_第5页
第5页 / 共11页
点击查看更多>>
下载资源
资源描述

matlab对图片加入噪声.docx

《matlab对图片加入噪声.docx》由会员分享,可在线阅读,更多相关《matlab对图片加入噪声.docx(11页珍藏版)》请在冰豆网上搜索。

matlab对图片加入噪声.docx

matlab对图片加入噪声

图片去噪:

对一幅图像加入不同的噪声(随机点噪声、椒盐噪声等),选取不同的方法去噪,比如说邻域平均、中值滤波、图像迭加等,比较对于不同的噪声,不同的方法哪种更好。

A.加入随机点噪声进行邻域平均、中值滤波、图像迭加

邻域平均

>>I=imread('D:

\gem.bmp');

>>snoise=0.1*randn(size(I));

>>J1=imadd(I,im2uint8(snoise));%受随机噪声干扰

>>M4=[010;101;010];

>>M4=M4/4;%4邻域平均滤波

>>I_filter1=filter2(M4,J1);

>>M8=[111;101;111];%8邻域平均滤波

>>M8=M8/8;

>>I_filter2=filter2(M8,J1);

>>subplot(2,2,1),imshow(I);title('原始图像Gem');

>>subplot(2,2,2),imshow(J1);title('加随机噪声后图像');

>>subplot(2,2,3),imshow(I_filter1,map);title('4邻域平均滤波');

>>subplot(2,2,4),imshow(I_filter2,map);title('8邻域平均滤波');

均值滤波

>>G=imread('D:

\gem.bmp');

>>I=rgb2gray(G);

>>snoise=0.1*randn(size(I));

>>A=imadd(I,im2uint8(snoise));

>>B1=filter2(fspecial('average',3),A)/255;

>>B2=filter2(fspecial('average',5),A)/255;

>>B3=filter2(fspecial('average',10),A)/255;

>>subplot(2,2,1),imshow(A);title('加随机噪声后图像');

>>subplot(2,2,2),imshow(B1);title('平均3后图像');

>>subplot(2,2,3),imshow(B2);title('平均5后图像');

>>subplot(2,2,4),imshow(B3);title('平均10后图像');

原图

B.加入椒盐噪声进行邻域平均、中值滤波、图像迭加

邻域平均

>>I=imread('moon.tif');

>>J=imnoise(I,'salt&pepper',0.02);

>>subplot(1,2,1),imshow(I);title('原图');

>>subplot(1,2,2),imshow(J);title('加噪');

>>K1=filter2(fspecial('average',7),J);

>>K2=filter2(fspecial('average',9),J);

>>figure,subplot(1,2,1),imshow(uint8(K1));title('3x3');

>>subplot(1,2,2),imshow(uint8(K1));title('5x5')

>>subplot(1,2,1),imshow(uint8(K1));title('7x7');

>>subplot(1,2,2),imshow(uint8(K1));title('9x9')

中值滤波

>>I=imread('moon.tif');

>>J=imnoise(I,'salt&pepper',0.02);

>>K1=medfilt2(J);

>>K2=medfilt2(J,[55]);

>>K3=medfilt2(J,[77]);

>>K4=medfilt2(J,[99]);

>>subplot(1,2,1),imshow(K1);title('3x3');

>>subplot(1,2,2),imshow(K2);title('5x5');

>>subplot(1,2,1),imshow(K3);title('7x7');

>>subplot(1,2,2),imshow(K4);title('9x9');

 

C.加入高斯噪声进行邻域平均、中值滤波、图像迭加

邻域平均

>>G=imread('D:

\gem.bmp');

>>I=rgb2gray(G);

>>J1=imnoise(I,'gaussian',0,0.02);%受高斯噪声干扰

>>M4=[010;101;010];

>>M4=M4/4;%4邻域平均滤波

>>I_filter1=filter2(M4,J1);

>>M8=[111;101;111];%8邻域平均滤波

>>M8=M8/8;

>>I_filter2=filter2(M8,J1);

>>subplot(2,2,1),imshow(I);title('原始图像Gem');

>>subplot(2,2,2),imshow(J1);title('加高斯噪声后图像');

>>subplot(2,2,3),imshow(I_filter1,map);title('4邻域平均滤波');

>>subplot(2,2,4),imshow(I_filter2,map);title('8邻域平均滤波');

>>subplot(2,2,3),imshow(B2);title('平均5后图像');

>>subplot(2,2,4),imshow(B3);title('平均7后图像');

 

均值滤波

>>I=imread('D:

\gem.bmp');

>>A=imnoise(I,'gaussian',0.01);

>>B1=filter2(fspecial('average',3),A)/255;

>>B2=filter2(fspecial('average',5),A)/255;

>>B3=filter2(fspecial('average',7),A)/255;

>>subplot(2,2,1),imshow(A);title('加高斯噪声后图像');

>>subplot(2,2,2),imshow(B1);title('平均3后图像');

>>subplot(2,2,3),imshow(B2);title('平均5后图像');

>>subplot(2,2,4),imshow(B3);title('平均7后图像');

 

D.图像迭加滤波

>>I=imread('pout.tif');

>>[mn]=size(I);

>>J1(m,n)=0;J2(m,n)=0;J3(m,n)=0;

>>fori=1:

10

temp=imnoise(I,'gaussian',0,0.01);

J1=J1+double(temp)/10;

end

>>fori=1:

20

temp=imnoise(I,'gaussian',0,0.01);

J2=J2+double(temp)/20;

end

>>fori=1:

50

temp=imnoise(I,'gaussian',0,0.01);

J3=J3+double(temp)/50;

end

>>figure;subplot(2,2,1),imshow(I),title('原图象');

>>;subplot(2,2,2),imshow(mat2gray(J1)),title('10次迭加滤波');

>>subplot(2,2,3),imshow(mat2gray(J2)),title('20次迭加滤波');

>>subplot(2,2,4),imshow(mat2gray(J3)),title('50次迭加滤波')

 

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 工程科技 > 机械仪表

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1