首页 > 解决方案 > 如何使用频域中的线性滤波器去除图像中的噪声?

问题描述

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

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

标签: matlabfrequency-domain

解决方案


请参阅此登月图像示例。 登陆月球

%=====================
clc;
clear all;
close all;
%=====================
im = imread('moonlanding.png');
%=====================
FT  = fft2(double(im));
%finding spectrum
FTS = fftshift(FT);
FTSG= log(FTS+1);
figure;
imshow(abs(FTSG),[]);
%imtool(abs(FTS),[]);
[m,n] = size(im);
%====================
t = 0:pi/10:2*pi;
% point around which we filter image
xc=(m+150)/2; 
yc=(n-150)/2;
%======================
figure;
subplot(221)
imshow(im);
%======================
for k = 1:3
%Radium of circular region of interest(for BRF)
%r=200;   
%r1 = 40;
r = 200;
r1 = 50*k;
%------------------------
xcc  = r*cos(t)+xc;
ycc  = r*sin(t)+yc;
xcc1 = r1*cos(t)+xc;
ycc1 = r1*sin(t)+yc;
%------------------------
mask  = poly2mask(double(xcc),double(ycc), m,n);
%generating mask for filtering
mask1 = poly2mask(double(xcc1),double(ycc1), m,n);

mask(mask1)=0;

FT2=FTS;
FT2(mask)=0;%cropping area or bandreject filtering
%========================
% Display Results
%imtool(abs(FT2),[]);
%subplot(211)
%imshow(abs(FT2),[]);
output = ifft2(ifftshift(FT2));
subplot(2,2,(k+1));
%imtool(output,[]);
imshow(abs(output),[]);
end

推荐阅读