运动模糊图像复原

1.维纳滤波

deconvwnr 用wiener滤波器实现图像去模糊
deconvreg 用regularized滤波器实现图像去模糊
deconvlucy 用Lucy-Richardson滤波器实现图像去模糊
deconvbind 用盲反卷积算法实现图像去模糊

题目是已知模糊核的,我们需要自己尝试不同的方差找到最合适的。

img=imread('motion.bmp');
img=im2double(img);
subplot(2,2,1),imshow(img),title("initial")
len=30;
theta=11;
PSF=fspecial("motion",len,theta);
sVar=var(img(:));

wnr1=deconvwnr(img,PSF,0);
subplot(2,2,2),imshow(wnr1),title("without using NSR")

wnr2=deconvwnr(img,PSF,0.0001/sVar);
subplot(2,2,3),imshow(wnr2),title("with using NSR=0.0001");

wnr3=deconvwnr(img,PSF,0.001/sVar);
subplot(2,2,4),imshow(wnr3),title("with using NSR=0.001");

figure(2),imshow(wnr2)

h=fspecial('average');
f=filter2(h,wnr2);
figure(3),imshow(f)

在这里插入图片描述
处理之后发现取0.001时效果最好,把图像去除,加以均值滤波(对于高斯噪声来说略优)。

2.模糊及逆滤波

使用imnoise对模糊后的图像加高斯噪声。
fspecial是定义核所用的,非常重要。

img=imread('work.jpg');
img=rgb2gray(img);
img=im2double(img);

len=28;
theta=14;
PSF=fspecial("motion",len,theta);
blurred=imfilter(img,PSF,'circular');
% motion blur
subplot(2,3,1),imshow(img),title("原图")
subplot(2,3,2),imshow(blurred),title("运动模糊")
If=fft2(blurred);
Pf=fft2(PSF,500,500);
deblurred=ifft2(If./Pf);
subplot(2,3,3),imshow(deblurred),title("直接逆滤波")

mean=0;
var=0.0001;
noised=imnoise(blurred,'gaussian',mean,var);
subplot(2,3,4),imshow(noised),title("模糊加噪声")

Ifn=fft2(noised);
deblurredn=ifft2(Ifn./Pf);
subplot(2,3,5),imshow(deblurredn),title("直接逆滤波")

在这里插入图片描述
呵呵,逆滤波不能处理有噪声的图像哦。

猜你喜欢

转载自blog.csdn.net/weixin_42231070/article/details/84288140