在matlab中使用FFT去除图像中的图案和噪声 [英] Removing pattern and noise in an image using FFT in matlab

查看:581
本文介绍了在matlab中使用FFT去除图像中的图案和噪声的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用clown.jpg图像来消除明显的模式/噪点。

I am using the clown.jpg image to be able to get rid of the obvious pattern/noise it has.

在拍摄图像之前,我做的第一步是重新调整两个幂的平方图像(即256 x 256)。在MATLAB中使用FFT和fftshift,以图像中心的强度为基础,进行快速傅立叶变换。以下图像是使用上述功能的结果。

The first step that I did before taking FFT of the image is to rescale it a square image of powers of two (i.e. 256 x 256). Using FFT and fftshift in matlab gives the fast fourier transform with the intensities centered in the image. The following image is the result of using the previous functions mentioned.

我成功地通过在FFT图像上手动归零星星来消除模式/噪点,如下所示:

I was successful to remove the pattern/noise by zeroing the "stars" manually on the FFT image as shown below:

采取IFFT,我得到一个更好的图片质量(未显示)。

Taking the IFFT I get a much better quality of picture (not shown).

我的问题是如果有自动方式归零星星?由于我们不想删除最亮的星,DC分量,也不是低值,我创建了一个图像零位置的间隔。这样的阈值如下:

The question that I have is if there is an automated way of zeroing the "stars"? I have created an interval of where to zero the images since we don't want to remove the brightest "star", the DC component, nor the low values. Such a threshold is given below:

filter = (fLog > .7*max(fLog(:)) ) | (fLog < .25*max(fLog(:)) )

where fLog is the log(1+abs(Fourier image)) and .7 and .25 are the corresponding
interval percentages.

下面找到输出掩码(我将乘以傅里叶图像)。黑色对应于0的值,白色对应于1.请注意,该掩码的过滤将删除一些星并保留一些直流分量。显然这种方法不是最好的。

The output mask (which I will multiply to the Fourier Image) is found below. Black corresponds to the value of 0 and white corresponds to 1. Notice that the filtering of this mask removes some "stars" and keeps some of the DC component. Obviously this method is not the best.

我正在阅读关于做高通滤波器,但这似乎删除了傅里叶图像中的所有外部值。这是基于我以前的测试(我没有包括那些图像)。

I was reading about doing a high pass filter, but that seems to remove all the outer values in the Fourier image. This is based on my previous testing (I didn't include those images).

有什么建议您突出显示除DC组件之外的高强度值。理想情况下,我想让面具看起来像:

Is there something that you recommend to highlight the high intensity values except the DC component. Ideally I would like to get the mask to look like:

来源: http://users.accesscomm.ca/bostrum/Imaging/tips/tip1.html

在另一个网站中,提到使用高通和水平校正FFT数据仅保留表示光栅图案的杂散点。我不清楚如何做到这一点。来源: http://www.robotplanet

In another site, it was mentioned to use "highpass and level correct the FFT data to retain only the stray dots that represent the raster pattern." I am unclear on how to do that exactly.

.dk / graphics / raster_removal /

source: http://www.robotplanet.dk/graphics/raster_removal/

您的帮助将不胜感激。

我的源代码帮助:

I = imread('clown.jpg'); % Read Image

% convert to grayscale
I = rgb2gray(I);

% normalize the image and conver to doubleI
I = double(mat2gray(I));

% Resize the image
I = imresize(I, [256 256]);

% get the size of the image
[rows,cols] = size(I);

% apply FFT
f = fftshift(fft2(I));

% used to plot the image
fLog = log(1 + abs(f));

% filter by a range based on fLog

filter = (fLog > .7*max(fLog(:)) ) | (fLog < .25*max(fLog(:)) );

B = abs(ifft2(f.*filter));

colormap(gray)
subplot(2,2,1),imagesc(I); title('Original Image')
subplot(2,2,2),imagesc(fLog); title('Fourier Image')
subplot(2,2,3),imagesc(filter); title('Zeroed Fourier Image')
subplot(2,2,4),imagesc(B); title('Cleaned Image')
annotation('textbox', [0 0.9 1 0.1], ...
    'String', 'Fourier Analysis on Clown Image', ...
    'EdgeColor', 'none', ...
    'HorizontalAlignment', 'center', ...
    'FontSize', 15, ...
    'FontWeight', 'bold')


推荐答案

我试图检测到频域,并将其与邻域一起归零。它不完全是干净的,但至少在一定程度上实现了一些自动调零。

I tried to detect the local maximum magnitude in the frequency domain, and zero them along with their neighborhoods. It is not exactly clean, but at least realize some automatic-zero to some extent.

我的代码:

I=I-mean(I(:));
f = fftshift(fft2(I));
fabs=abs(f);

roi=3;thresh=400;
local_extr = ordfilt2(fabs, roi^2, ones(roi));  % find local maximum within 3*3 range

result = (fabs == local_extr) & (fabs > thresh);

[r, c] = find(result);
for i=1:length(r)
    if (r(i)-128)^2+(c(i)-128)^2>400   % periodic noise locates in the position outside the 20-pixel-radius circle
        f(r(i)-2:r(i)+2,c(i)-2:c(i)+2)=0;  % zero the frequency components
    end
end

Inew=ifft2(fftshift(f));
imagesc(real(Inew)),colormap(gray),

这篇关于在matlab中使用FFT去除图像中的图案和噪声的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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