1.均值、中值、高斯、维纳图像去噪
clc
clear
g = rgb2gray(imread('chuzao.jpg'));
zyy = imread('y.jpg');
g1 = imfilter(g, fspecial('average'));%均值滤波
g2 = medfilt2(g, [3 3]); %3*3中值滤波
h_gaosi1 = fspecial('gaussian',3,1);
g3 = imfilter(g, h_gaosi1); %高斯平滑滤波
g4 = wiener2(g,[5 5]); %5*5维纳滤波
subplot(3, 2, 1), imshow(zyy), title('原图');
subplot(3, 2, 2), imshow(g), title('待处理噪声');
subplot(3, 2, 3), imshow(g1), title('均值滤波');
subplot(3, 2, 4), imshow(g2), title('中值滤波');
subplot(3, 2, 5), imshow(g3), title('高斯平滑滤波');
subplot(3, 2, 6), imshow(g4), title('维纳滤波');
%下面是计算PSNR和SSIM的程序口令
psnr(zyy,g)
psnr(zyy,g1)
psnr(zyy,g2)
psnr(zyy,g3)
psnr(zyy,g4)
ssim(zyy,g1)
ssim(zyy,g2)
ssim(zyy,g3)
ssim(zyy,g4)
2.小波重构除噪
clc
clear;
zyy = imread('y.jpg'); %读取原图像
subplot(221);
imshow(zyy);
title('原图');
X=imread('chuzao.jpg');
X=rgb2gray(X);
subplot(222);
imshow(X);