如何使用频域中的线性滤波器消除图像中的噪声? [关闭]

问题描述 投票:0回答:1

因此,我使用了Spatial域中的线性滤波器,但是在频域中,我很难理解如何在Matlab中实现任何滤波器。谁能解释我该怎么做?

我想看看如何使用频域中的滤波器来消除图像中的噪声。

matlab frequency-domain
1个回答
-2
投票

@ jodag-reinstate-monica-link多亏了Stack Overflow上的这篇文章,他们用一个很好的例子很好地解释了这一点。find-proper-notch-filter-to-remove-pattern-from-image

I = imread('YmW3f.png');
ft = fftshift(fft2(I));
[m,n] = size(ft);

% define some functions
norm_img = @(img) (img - min(img(:))) / (max(img(:)) - min(img(:)));
show_spec = @(img) imshow(norm_img(log(abs(img)-min(abs(img(:)))+1.0001)));
gNotch = @(v,mu,cov) 1-exp(-0.5*sum((bsxfun(@minus,v,mu).*(cov\bsxfun(@minus,v,mu)))));

% show spectrum before
figure();
show_spec(ft);

% by inspection
cx = 129;
cy = 129;

% distance of noise from center
wx1 = 149.5-129;
wx2 = 165.5-129;
wy  = 157.5-129;

% create notch filter
filt = ones(m,n);

% use gaussian notch with standard deviation of 5
sigma = 5;
[y,x] = meshgrid(1:n, 1:m);
X = [y(:) x(:)].';
filt = filt .* reshape(gNotch(X,[cx+wx1;cy+wy],eye(2)*sigma^2),[m,n]);
filt = filt .* reshape(gNotch(X,[cx+wx2;cy+wy],eye(2)*sigma^2),[m,n]);
filt = filt .* reshape(gNotch(X,[cx-wx1;cy-wy],eye(2)*sigma^2),[m,n]);
filt = filt .* reshape(gNotch(X,[cx-wx2;cy-wy],eye(2)*sigma^2),[m,n]);

% apply filter
ft = ft .* filt;

% show spectrum after
figure();
show_spec(ft);

% compute inverse
ifft_ = ifft2(ifftshift( ft));
img_res = histeq(norm_img(ifft_));

figure();
imshow(img_res);
© www.soinside.com 2019 - 2024. All rights reserved.