图像恢复

本文通过Matlab实现维纳滤波和逆滤波技术,探讨了这两种方法在图像模糊修复中的应用。展示了不同噪声条件下的图像修复效果,并讨论了信噪比对修复质量的影响。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

###维纳滤波—deconvwnr函数利用维纳滤波器来对图像模糊修复

function image_restoration_deconvwnr()
    %Read image
    I = im2double(imread('lena.tif'));
    I=rgb2gray(I);
    figure,subplot(2,3,1),imshow(I);
    title('Original Image');

    %Simulate a motion blur
    LEN = 21;
    THETA = 11;
    PSF = fspecial('motion', LEN, THETA);
    blurred = imfilter(I, PSF, 'conv', 'circular');
    subplot(2,3,2),imshow(blurred);
    title('Blurred Image');

    %Restore the blurred image
    wnr1 = deconvwnr(blurred, PSF, 0);
    subplot(2,3,3),imshow(wnr1);
    title('Restored Image');

    %Simulate blur and noise
    noise_mean = 0;
    noise_var = 0.0001;
    blurred_noisy = imnoise(blurred, 'gaussian', ...
                            noise_mean, noise_var);
    subplot(2,3,4),imshow(blurred_noisy)
    title('Simulate Blur and Noise')

    %Restore the blurred and noisy image:First attempt
    wnr2 = deconvwnr(blurred_noisy, PSF, 0);
    subplot(2,3,5);imshow(wnr2);title('Restoration of Blurred, Noisy Image Using NSR = 0')

    %Restore the Blurred and Noisy Image: Second Attempt
    signal_var = var(I(:));
    wnr3 = deconvwnr(blurred_noisy, PSF, noise_var / signal_var);
    subplot(2,3,6),imshow(wnr3)
    title('Restoration of Blurred, Noisy Image Using Estimated NSR');
end

这里写图片描述

####维纳滤波需要估计图像的信噪比(SNR)或者噪信比(NSR),信号的功率谱使用图像的方差近似估计,噪声分布是已知的。从第一排中可以看出,若无噪声,此时维纳滤波相当于逆滤波,恢复运动模糊效果是极好的。从第二排可以看出噪信比估计的准确性对图像影响比较大的,二排中间效果几乎不可用。

###逆滤波

function image_restoration_matlab()
    % Display the original image.
    I = im2double(imread('lena.tif'));
    I=rgb2gray(I);
    [hei,wid,~] = size(I);
    subplot(2,3,1),imshow(I);
    title('Original Image (courtesy of MIT)');


    % Simulate a motion blur.
    LEN = 21;
    THETA = 11;
    PSF = fspecial('motion', LEN, THETA);
    blurred = imfilter(I, PSF, 'conv', 'circular');
    subplot(2,3,2), imshow(blurred); title('Blurred Image');

    % Inverse filter
    If = fft2(blurred);
    Pf = fft2(PSF,hei,wid);
    deblurred = ifft2(If./Pf);
    subplot(2,3,3), imshow(deblurred); title('Restore Image')

    % Simulate additive noise.
    noise_mean = 0;
    noise_var = 0.0001;
    blurred_noisy = imnoise(blurred, 'gaussian', ...
                            noise_mean, noise_var);
    subplot(2,3,4), imshow(blurred_noisy)
    title('Simulate Blur and Noise')

    % Try restoration assuming no noise.
    If = fft2(blurred_noisy);
    deblurred2 = ifft2(If./Pf);
    subplot(2,3,5), imshow(deblurred2)
    title('Restoration of Blurred Assuming No Noise');

    % Try restoration with noise is known.
    noisy = blurred_noisy - blurred;
    Nf = fft2(noisy);
    deblurred2 = ifft2(If./Pf - Nf./Pf);
    subplot(2,3,6), imshow(deblurred2)
    title('Restoration of Blurred with Noise Is Known')
end

这里写图片描述
####逆滤波对噪声非常敏感,除非我们知道噪声的分布情况(事实上,这也很难知道),逆滤波几乎不可用,可以从二排中间看出,恢复图像效果极差。但若知道噪声分布,也是可以完全复原信息的。可以从二排最后一张图可以看出。

参考文献:
数字图像处理matlab版(左飞)
数字图像处理第三版(Gonzalez)
http://blog.youkuaiyun.com/zhoufan900428/article/details/38064125
http://blog.youkuaiyun.com/bluecol/article/details/47357717
http://blog.youkuaiyun.com/bluecol/article/details/46242355

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值