图像处理深度学习-推荐系统-CV-NLP图像处理

直接生成频域滤波

2015-11-29  本文已影响178人  在河之简

接上文:傅立叶变换滤波

频域滤波器

理想低通滤波器


Paste_Image.png
Paste_Image.png

巴特沃兹低通滤波器


Paste_Image.png

高斯低通滤波器


Paste_Image.png

dftuv的实现

dftuv函数的作用是 生成频域的距离向量组。这个距离是距离频域中心的距离

function [U, V] = dftuv(M, N)
%DFTUV Computes meshgrid frequency matrices.
%   [U, V] = DFTUV(M, N) computes meshgrid frequency matrices U and
%   V.  U and V are useful for computing frequency-domain filter
%   functions that can be used with DFTFILT.  U and V are both
%   M-by-N.

%   Copyright 2002-2004 R. C. Gonzalez, R. E. Woods, & S. L. Eddins
%   Digital Image Processing Using MATLAB, Prentice-Hall, 2004
%   $Revision: 1.3 $  $Date: 2003/04/16 22:30:34 $

% Set up range of variables.
u = 0:(M - 1);
v = 0:(N - 1);

% Compute the indices for use in meshgrid.
idx = find(u > M/2);
u(idx) = u(idx) - M;
idy = find(v > N/2);
v(idy) = v(idy) - N;

% Compute the meshgrid arrays.
[V, U] = meshgrid(v, u);

直接用频域高斯低通滤波的例子

clear all;
close all;
f=imread('E:\资料\onedrive\code\test\image\Fig0413(a)(original_test_pattern).tif');
PQ=paddedsize(size(f));
% 生成低通滤波器(注意大小) 移动
[U,V]=dftuv(PQ(1),PQ(2));
D0=0.05*PQ(2);
H=exp(-1*(U.^2+V.^2)/(2*D0.^2));
H1=fftshift(H);
% 滤波输出结果
g=dftfilt(f,H);
f1=fft2(f);
myImshow(f);myImshow(H1); myImshow(g);myImshow(0);

运行结果

untitled.png

用高通滤波进行图像锐化

Paste_Image.png

用图像的原始频率同时在高频部分进行增强。(拉普拉斯检测边缘也是检测的高频部分其实)
% % % % % % % % % % % % % % % %% % % % % % % % % % % % % % % %
% 用高通滤波做频域增强
% % % % % % % % % % % % % % % %% % % % % % % % % % % % % % % %
% 读取图片

clear all;
close all;
f=imread('E:\资料\onedrive\code\test\image\Fig0419(a)(chestXray_original).tif');
% 生成波特沃兹滤波器
PQ=paddedsize(size(f));
[U,V]=dftuv(PQ(1),PQ(2));
D0=0.05PQ(2);
n=[1,5,15,50];
% D0=[15,30,80];
myImshow(gscale(f));
for i=1:numel(n);
b=((U.2+V.2)/(D0.2)).n(i);
H=b/(b+1);
%myImshow(H);
% 按照公式进行运算
Hh=0.5+2
H;
g=dftfilt(f,Hh);
g=histeq(gscale(g),256);
myImshow(g);
end
myImshow(0);

运行结果

untitled.png
上一篇下一篇

猜你喜欢

热点阅读