matlab - 如何使用频域中的线性滤波器去除图像中的噪声?
问题描述
因此,我使用了空间域中的线性滤波器,但在频域中,我很难理解如何在 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
推荐阅读
- reactjs - 为什么 window.location.pathname 在一个函数中起作用,而在另一个函数中不起作用?
- c - 如何将循环的最终结果作为 int 以供进一步使用?
- python-3.x - 为什么我的 lambda/alexa 托管技能权限被拒绝?
- c++ - Clang++ 使链接器在模板类上失败(但它适用于 g++)
- typescript - 对象字面量只能指定已知的属性,而 'id' 不存在于类型 'ModelAttributes' 中
- pandas - Seaborn:如何在绘图的 X 轴上的每个值之后添加一个“%”符号,而不是将值转换为百分比?
- javascript - 词过滤javascript
- android - 将框架布局放置在 ConstraintLayout 中的工具栏下方
- python - scipy.integrate.solve_ivp 有问题
- c# - C# Google 地理编码:即使遵循所需的步骤,也会不断获得权限被拒绝