数字图像处理matlab代码
一、1
a=imread('C:\Users\SUN\Desktop\A\a.tif'); %读图像
b=imnoise(a,'gaussian',0,0.012); %加入0均值,方差800的噪声。
c=imnoise(b,'salt & pepper',0.1); % 在(a)的基础上,进一步加入椒盐噪声进一步污染图像( Pa=Pb=0.1的椒盐噪声)
subplot(2,4,1),imshow(a) ,title('原始图像') %显示图片
subplot(2,4,2),imshow(b) ,title('高斯噪声污染')
subplot(2,4,3),imshow(c) ,title('椒盐噪声污染')
g1= imfilter(c,fspecial('average',5));
subplot(2,4,4),imshow(g1) ,title('算数均值滤波')
h=ones(5,5)/25; %几何均值滤波
g2=imfilter(c,h);
subplot(2,4,5),imshow(g2) ,title('几何均值滤波')
g3= medfilt2(c,[5,5]); %中值滤波
subplot(2,4,6),imshow(g3) ,title('中值滤波')
i=ones(5,5)/20;
g4=imfilter(c,i);
subplot(2,4,7),imshow(g4) ,title('修正后的α均值滤波')
2
a=imread('C:\Users\SUN\Desktop\A\a.tif'); %读图像
b=imnoise(a,'gaussian',0,0.015); %加入0均值,方差1000的噪声
subplot(2,3,1),imshow(a) ,title('原始图像') %显示图片
subplot(2,3,2),imshow(b) ,title('高斯噪声污染')
g1= imfilter(b,fspecial('average',7));
subplot(2,3,4),imshow(g1) ,title('算数均值滤波') %算数均值滤波
h=ones(7,7)/49; %几何均值滤波
g2=imfilter(b,h);
subplot(2,3,5),imshow(g2) ,title('几何均值滤波')
g3=wiener2(b,[7,7]);
subplot(2,3,6),imshow(g3) ,title('自适应噪声消减滤波') %自适应噪声消减滤波
3
a=imread('C:\Users\SUN\Desktop\A\a.tif'); %读图像
b=imnoise(a,'salt & pepper',0.25); %加入概率Pa=Pb=0.25的椒盐噪声污染了的图像
subplot(2,2,1),imshow(a) ,title('原始图像') %显示图片