1、采用二维中值滤波函数medfilt2 对受椒盐噪声干扰的图像滤波,窗口分别采用3*3,5*5,7*7
i = imread('D:\study\third_down\ImageProcessing\work\work_one\flower.jpg');
I = rgb2gray(i);
J = imnoise(I,'salt & pepper',0.04);
K1 = medfilt2(J,[3 3]);%对矩阵I进行二维中值滤波,领域为3*3
K2 = medfilt2(J,[5 5]);
K3 = medfilt2(J,[7 7]);
subplot(2,2,1);imshow(J);title('盐椒噪声干扰图像');
subplot(2,2,2);imshow(K1);title('领域为3*3二维中值滤波');
subplot(2,2,3);imshow(K2);title('领域为5*5二维中值滤波');
subplot(2,2,4);imshow(K3);title('领域为7*7二维中值滤波');
2 、采用 MATLAB 中的函数 filter2 对受噪声干扰的图像进行均值滤波
i = imread('D:\study\third_down\ImageProcessing\work\work_fourth\flower.jpg');
j = imnoise(i,'gaussian',0,0.02);%模拟均值为0方差为0.02的高斯噪声
M = filter2(fspecial('average',9),j)/255;%模板尺寸为9
subplot(2,1,1);imshow(j);title('噪声干扰图像');
subplot(2,1,2);imshow(M);title('均值滤波后的图像');
3.采用三种不同算子对图像进行锐化处理
i = imread('D:\study\third_down\ImageProcessing\work\work_fourth\flower.jpg');
I = rgb2gray(i);
H = fspecial('sobel');%应用sobel算子锐化图像
I1 = filter2(H,I);%算子滤波锐化
H = fspecial('prewitt');%应用prewitt算子锐化图像
I2 = filter2(H,I);%算子滤波锐化
H = fspecial('log');%应用log算子锐化图像
I3 = filter2(H,I);%算子滤波锐化
subplot(2,2,1);imshow(i);title('原图像');
subplot(2,2,2);imshow(I1);title('应用sobel算子锐化图像');
subplot(2,2,3);imshow(I2);title('应用prewitt算子锐化图像');
subplot(2,2,4);imshow(I3);title('应用log算子锐化图像');