【数字图像处理Matlab】- 实验二:图像噪声及图像复原

2.1 编程实现:复原由运动模糊+高斯噪声造成的退化图像,对比逆滤波、维纳滤波以及最小二乘方滤波方法。

代码如下:

I = imread('005.bmp');
I = im2double(I);
subplot(3, 3, 1),imshow(I),title('原始图像');
IG = rgb2gray(I);
subplot(3, 3, 2),imshow(IG),title('灰度图像');
len = 30;
theta = 45;
PSF = fspecial('motion',len,theta);
MF = imfilter(IG,PSF,'circular');
subplot(3, 3, 3),imshow(MF),title('运动模糊图像');
noise = imnoise(zeros(size(MF)),'gaussian',0,0.0001);
MFN = MF + noise;
subplot(3, 3, 4),imshow(MFN,[]),title('增加高斯噪声');
NSR = sum(noise(:).^2)/sum(MFN(:).^2);
subplot(3, 3, 5),imshow(deconvwnr(MF,PSF),[]),title('无噪声图片逆滤波复原');
subplot(3, 3, 6),imshow(deconvwnr(MFN,PSF),[]),title('有噪声图片逆滤波复原');
subplot(3, 3, 7),imshow(deconvwnr(MFN,PSF,NSR),[]),title('维纳滤波复原');
[H,W] = size(MF);
y = H*W*0.0001;
subplot(3, 3, 8),imshow(deconvreg(MFN,PSF,y/3),[]),title('约束最小二乘方滤波复原');

实验结果:

【数字图像处理Matlab】- 实验二:图像噪声及图像复原_第1张图片

2.2 编程实现:复原由噪声引起的退化图像。

代码:

IG = imread('image5-IG.bmp'); 
subplot(2, 3, 1),imshow(IG),title('原始图像');
IN = imnoise(IG,'salt & pepper',0.2);
subplot(2, 3, 2),imshow(IN),title('椒盐噪声');
INt = double(IN)/255;
subplot(2, 3, 3),imshow(medfilt2(INt,'symmetric')),title('中值滤波');
subplot(2, 3, 4),imshow(ordfilt2(INt,median(1:3*3),ones(3,3),'symmetric')),title('中点滤波');
subplot(2, 3, 5),imshow(ordfilt2(INt,1,ones(3,3))),title('最小值滤波');
subplot(2, 3, 6),imshow(ordfilt2(INt,9,ones(3,3))),title('最大值滤波');

实验结果:

【数字图像处理Matlab】- 实验二:图像噪声及图像复原_第2张图片

你可能感兴趣的:(数字图像处理,Matlab,数字图像处理,Matlab)