使用傅立叶变换从图像中去除周期性噪声 [英] Removing periodic noise from an image using the Fourier Transform

查看:2244
本文介绍了使用傅立叶变换从图像中去除周期性噪声的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在对特定图像执行2D FFT,并获得其光谱分量。现在,此图像已与另一个图像叠加,以产生周期性噪声。



原始图像以及周期性噪声版本如下所示:



原始图像





定期噪声图像





为了对此进行过滤,我使用了掩盖幅度谱中组件的手动框与其他组件相比非常大,如下所示。





完成此操作后,我执行了逆FFT,但我没有得到原始图像。





有谁知道我在做什么错误?



这是屏蔽这些值然后继续对屏蔽光谱图像进行逆2D FFT的代码:

  pat1 = imread('Pattern1.png'); 

spec_orig = fft2(double(pat1));
spec_orig2 = abs(spec_orig);
spec_img = fftshift(spec_orig2);

对于j = 115:125
对于n = 96:106
spec_img(n,j)= 0;
结束
,n = 216:226
spec_img(n,j)= 0;
结束
,n = 274:284
spec_img(n,j)= 0;
结束
,n = 298:308
spec_img(n,j)= 0;
结束
,n = 12:22
spec_img(n,j)= 0;
结束
,n = 37:47
spec_img(n,j)= 0;
end
end

%获取Pattern1的图像
figure; subplot(2,1,1);
spec_img = log(1 + spec_img);
imshow(spec_img,[]);

subplot(2,1,2);
ptnfx = ifft2(spec_img);
imshow(ptnfx);


解决方案

在频域过滤是一项棘手的工作对。您的代码有一些错误阻止您重建原始图像:


  1. 您正在应用过滤只有幅度成分。您必须在原始图像光谱上执行此操作,而不仅仅是幅度组件。这个阶段对于正确的重建至关重要。顺便说一下,要实现一个信号处理术语,你正在实施的是



    我将添加的原始图像的相当好的重建。你仍会看到一些条纹,这在很大程度上取决于陷波滤波器的形状和大小。也许使尺寸更大,甚至更大,使陷波滤波器的形状为圆形而不是方形。由于方块的边角引入的硬边缘具有意想不到的响铃效果,因此倾向于保留更多的原始图像。


    I am performing the 2D FFT on a particular image and I get its spectral components. Now this image has been superimposed with another image to create periodic noise.

    The original image as well as the periodic noise version is shown below:

    Original Image

    Periodic Noise Image

    To filter this out, I used manual boxes that masked the components in the magnitude spectrum that are quite large relative to the other components as shown below.

    After this is done, I perform an inverse FFT, but I do not get the original image back.

    Does anyone know what I'm doing wrong?

    Here is the code that masks the values and then proceeds to do an inverse 2D FFT on the masked spectral image:

    pat1 = imread('Pattern1.png');
    
    spec_orig = fft2(double(pat1));     
    spec_orig2 = abs(spec_orig); 
    spec_img = fftshift(spec_orig2);
    
    for j = 115:125
        for n = 96:106
            spec_img(n,j) = 0; 
        end
        for n = 216:226
            spec_img(n,j) = 0; 
        end
        for n = 274:284
            spec_img(n,j) = 0; 
        end
        for n = 298:308
            spec_img(n,j) = 0; 
        end
        for n = 12:22
            spec_img(n,j) = 0; 
        end
        for n = 37:47
            spec_img(n,j) = 0; 
        end
    end
    
    %Getting Back the Image for Pattern1
    figure;subplot(2,1,1);
    spec_img = log(1 + spec_img);
    imshow(spec_img,[]); 
    
    subplot(2,1,2);
    ptnfx = ifft2(spec_img);
    imshow(ptnfx);
    

    解决方案

    Filtering in the frequency domain is a tricky business to get right. Your code has a few errors that are preventing you from reconstructing the original image:

    1. You are applying the filtering on the magnitude component only. You have to do this on the original image spectrum, not just the magnitude component. The phase is essential for proper reconstruction. BTW, to coin a signal processing term, what you are implementing is a notch filter or a band-stop filter, which removes certain select frequencies.

    2. You centered the spectrum via fftshift but after you filtered you forgot to undo the shift. You must invoke ifftshift on your resulting filtered image to undo the centering.

    3. You're finding the inverse FFT of the log-transformed image. Remember that performing a log transform of the spectrum is only for display purposes. You do not use this when filtering or finding the inverse. Doing this will give you unintended consequences as the majority of the spectrum has been changed due to a non-linear operation. You have to do it on the original image spectrum itself.

    4. A minor note, but make sure you call real after you filter the result after you take the inverse FFT. There are most likely some residual imaginary components that are due to computational floating-point errors and so calling real will only extract the real components of the signal.

    With these corrections, this is the code I have. I've read your image directly from StackOverflow to be reproducible:

    pat1 = imread('http://i.stack.imgur.com/oIumJ.png');
    
    %// Change
    spec_orig = fft2(double(pat1)); 
    spec_img = fftshift(spec_orig);
    
    for j = 115:125
        for n = 96:106
            spec_img(n,j) = 0; 
        end
        for n = 216:226
            spec_img(n,j) = 0; 
        end
        for n = 274:284
            spec_img(n,j) = 0; 
        end
        for n = 298:308
            spec_img(n,j) = 0; 
        end
        for n = 12:22
            spec_img(n,j) = 0; 
        end
        for n = 37:47
            spec_img(n,j) = 0; 
        end
    end
    
    %// Change
    ptnfx = real(ifft2(ifftshift(spec_img)));
    imshow(ptnfx,[]);
    

    I get this image:

    A pretty good reconstruction of the original image I'll add. You'll still see a bit of streaking and that is highly dependent on the notch filter shape and size. Perhaps make the size bigger and even more so, make the shape of the notch filter circular instead of square. This has a tendency to preserve more of the original image as hard edges introduced by the corners of the squares have unintended ringing effects.

    这篇关于使用傅立叶变换从图像中去除周期性噪声的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆