如何使用频域中的线性滤波器去除图像中的噪声?
How can I use a linear filter from the frequency domain to remove noise in an image?
所以我在空间域中使用线性滤波器,但在频域中我很难理解如何在 Matlab 中实现任何滤波器。谁能解释我该怎么做?
我想了解如何使用频域滤波器去除图像中的噪声。
请参阅此登月图像示例。
%=====================
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
所以我在空间域中使用线性滤波器,但在频域中我很难理解如何在 Matlab 中实现任何滤波器。谁能解释我该怎么做?
我想了解如何使用频域滤波器去除图像中的噪声。
请参阅此登月图像示例。
%=====================
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