1.增加椒盐噪声并进行中值滤波
I=imread(‘C:\Users\acer\Pictures\Saved Pictures\1.jpg’);
I=rgb2gray(I);
subplot(2,2,1)
imshow(I)
title(‘原始图’);
P2=imnoise(I,‘salt & pepper’,0.02);
subplot(2,2,2)
imshow(P2)
title(‘椒盐噪声图’);
P3=medfilt2(P2);
subplot(2,2,3)
imshow(P3)
title(‘中值滤波后’);
2.拉普拉斯锐化
I=imread(‘C:\Users\acer\Pictures\Saved Pictures\1.jpg’);
I=rgb2gray(I);
P2=imnoise(I,‘salt & pepper’,0.02);
P3=medfilt2(P2);
P4=fspecial(‘laplacian’,0);
g1=imfilter(I,P4,‘replicate’);
g=I-g1;
subplot(2,2,1)
imshow(g)
title(‘原始图像的拉普拉斯锐化’);
g2=imfilter(P2,P4,‘replicate’);
g3=P2-g2;
subplot(2,2,2)
imshow(g3)
title(‘加入椒盐噪声后的拉普拉斯锐化’);
g4=imfilter(P3,P4,‘replicate’);
g5=P3-g4;
subplot(2,2,3)
imshow(g5)
title(‘平滑后图像的拉普拉斯锐化’);
3.增加噪声并去除噪声和平滑