The values of fx are multiplied by sines and cosines of various frequencies © The domain values of u of Fu is appropriately called frequency domain because u determines the frequency of
Trang 1Chapter4 Frequency Domain
Processing
Image Enhancement in the
Frequency Domain
Trang 3Introduction to the Fourier Transform
« Any function that periodically repeats itself can be expressed as the sum of sines and/or cosines of different frequencies, each multiplied by a different coefficient (Fourier series)
+» Even functions that are not periodic (but whose area under the curve is finite) can be expressed as the integral of sines and/or cosines multiplied by a weighting function (Fourier transform)
» The advent of digital computation and the “discovery” of fast
revolutionized the field of signal processing, and allowed for the first time practical processing and meaningful interpretation of
importance.
Trang 5Frequency Domain Processing
[\ AMAA AY
VỤ UVVVVV
Trang 61D Fourier transform and Its inverse
Trang 72D Fourier transform and Its inverse
Trang 8
Discrete Fourier Transform
(Discrete Fourier transform, DFT)
© The multiplier 1/M in front of the Fourier transform
sometimes is placed in front of the Inverse instead
© Or, both equations are multiplied by 1/VM
Trang 9Discrete Fourier Transform
© Each term of the Fourier transform is composed of the sum of all values
fo the function f(x) The values of f(x) are multiplied by sines and cosines
of various frequencies
© The domain (values of u) of F(u) is appropriately called frequency
domain because u determines the frequency of the components of the transform
Trang 10Discrete Fourier Transform
The Fourier transform may be viewed as a *‘mathematical prism” that separates
a function into various components based on frequency content
In the analysis of complex numbers, it is convinient to express F(u) in polar
Trang 112D DFT and Inverse DFT (IDFT)
x, y: image pixel position
u, VU: spatial frequency
Trang 12Filtering in frequency domain
+ Low-pass filters: preserve low frequencies, useful for noise suppression
useful for edge detection
Trang 13Filtering in frequency domain
Trang 14Computing and visualizing DFT
original Image Fourier spectrum
Trang 15Computing and visualizing DFT
Trang 16
Computing and visualizing DFT
original Image Fourier tranform fft2
ifft2
Trang 17Computing and visualizing DFT
subplot(2, 2, 1), mmshow(]); title(original Image’, 'FontSize',14)
subplot(2, 2, 2);imshow(F);title(‘Fourier tranform fft2",
'FontSize',14)
subplot(2, 2, [3 4]); imshow(F0);title( Centered spectrum:
ifft2', ‘'FontSize',14)
Trang 18Filtering in the frequency domain
ƒ(x,y)*ñh(x, y) © Alu,v)F (u,v)
The convolution theorem:
+» Linear spatial convolution is by convolving f(x,y) and
h(x,y) The same result is obtained in the frequency domain
by multiplying F(u,v) and H(u,yv)
« The basic idea in frequency domain is to select a filter transfer function that modifies F(u,v) in a specified manner + A filter is called low pass filter if it attenuates the high
frequency components to F(u,v) while leaving the low frequencies relatively unchanged.
Trang 20Filtering in the frequency domain
-0.0000 0.0000 -0.0000 -0.0000
0.0000 0.0000
1.0000 2.0000 3.0000 0.0000
6.0000 -0.0000 9.0000 0
-0.0000 0.0000 0.0000 0.0000
-0.0000 0.0000 0.0000 0.0000 0.0000 -0.0000 0.0000
Trang 21+ It is more efficient to use the Fourier transform than
a spatial filter for a large filter
* The Fourier Transform also allows us to isolate and process particular image frequencies and so perform low-pass and high-pass filtering with a great degree
of precision.
Trang 22Paddedsize function
function PQ = paddedsize(AB, CD, PARAM)
% PQ(1) = PQ(2) = 24nextpow2(2*m), where m is MAX({[AB CD])
if nargin ==
PQ = 2*AB; elseif nargin == 2&~ischar(CD)
PQ = AB + CD - 1; PQ =2 * ceil(PQ / 2);
elseif nargin == 2
m = max(AB); % Maximum dimension
% Find power-of-2 at least twice m
Trang 24
Paddedsize function
Trang 26function H = Ipfilter(tyoe, M, N, DO, n)
Trang 27function [U, V] = dftuv(M, N)
function [U, V] = dftuv(M, N)
%DETUV Computes meshgrid frequency matrices
% [U, V] = DF TUV(M, N) computes mesherid frequency matrices U and
% V.U and V are useful for computing frequency-domain filter
% functions that can be used with DF TFILT U and V are both M-by-N
% Set up range of variables
% Compute the meshørid arrays
[Y, U] = meshgrid(v, u);
Trang 32Application of function g = aftfilt(f, H)
Trang 33Obtain Frequency Domain Filters from Spatial Filters
Consider the image, f, of size 600 X 600 pixels shown in
following figure In what follows, we generate the frequency
domain filter, H, corresponding to the Sobel spatial filter that
enhance vertical edges We then compare the result of
filtering f in the spatial domain with the Sobel mask process
in the frequency domain.
Trang 34ain Filters from Spatial Filters
Trang 35Obtain Frequency Domain Filters from Spatial Filters
Trang 36Obtain Frequency Domain Filters from Spatial Filters
Trang 38Obtain Frequency Domain Filters from Spatial Filters
Trang 39Obtain Frequency Domain Filters from Spatial Filters
Trang 40Obtain Frequency Domain Filters from Spatial Filters
Trang 41Smoothing Frequency-Domain Filters
+ The basic model for filtering in the frequency domain
where F(u,v): the Fourier transform of the image to be
« There are several standard forms of lowpass filters (LPF)
— Ideal lowpass filter
— Butterworth lowpass filter
— Gaussian lowpass filter
Trang 42Ideal Lowpass Filters (ILPFs)
The simplest lowpass filter 1s a filter that “‘cuts off’ all high-
frequency components of the Fourier transform that are at a
distance greater than a specified distance D, from the origin of
Trang 43Ideal Lowpass Filters (ILPFs)
ILPF is a type of “nonphysical” filters and can't
be realized with electronic components and is not
very practical
Trang 46ideal Lowpass Filters (ILPFs)
enna ae
Trang 47Butterworth Lowpass Filters (BLPFs) with order n
between order n and
The BLPF may be viewed as a transition between ILPF AND
GLPF, BLPF of order 2 is a good compromise between
effective lowpass _ fitering and acceptable ringing characteristics
Trang 49
Gaussian Lowpass Filters (FLPFs)
Trang 50Gaussian Lowpass Filters (FLPFs)
Trang 51Gaussian Lowpass Filters (FLPFs)
Prom AE E3 ars nasa
File Edit View Insert Tools Desktop Window Help MÔ Fe Edit View Insert Tools Desktop Window Help
File Edit View Insert Tools Desktop Window Help = JP File Edit View Insert Tools Desktop Window Help ™
Trang 53Gaussian Lowpass Filters (FLPFs)
Trang 54Gaussian Lowpass Filters (FLPFs)
DO=10; H=exp(-(U.42+V.%2)/(2*(D0“%2))); ø=dftfilt Œ, H);
subplot(2, 3, 1), mmshow(ø.| |); tide( D0=10”, 'FontSize’, 16)
DŨ=1S; H=exp(-(U.^2+YV.^2)/(2*(D0^2))); ø1=dftfit (f., H);
subplot(2, 3, 2),mshow(ø1.|]); tie( D0=1S, 'FontSize’, 16)
D0=30; H=exp(-(U.^2+YV.^2)/(2*(D0^2))); ø2=dftfit (f H);
subplot(2, 3, 3),mshow(ø2.[]); tie( D0=30”, 'EontS1ze', 16)
DO0=60; H=exp(-(U.42+V.%2)/(2*(D0%2))); g3=dithilt , H);
subplot(2, 3, 4),mshow(ø3.|]) ; tile( D0=60", 'FontSize', 16)
DO0=80; H=exp(-(U.42+V.%2)/(2*(D0%2))); g4=dithilt i, H);
subplot(2, 3, 5),mshow(ø4.| |); title "D0=80'," 'EontS1ze', 16)
D0=230; H=exp(-(U.^2+VY.^2)/(2*(D0^2))); ø5=dftilt ( H);
subplot(2, 3, 6),mshow(ø5.[]); tile(D0=200", Kon(tS1ze, 16)
Trang 55Gaussian Lowpass Filters (FLPFs)
D0=30
Trang 56
Wireframe ano) Surface Plotting
+ Basic syntax:
mesh (H)
+ This function draws a wireframe for x=1:M, y=1:N,where
[M,.N]Z=size(H) If M and N are large, plot typically are
unacceptable So usually using:
mesh (H(1:K:end,1:K:end))
+ MATLAB plots mesh fihures in color , by default The
command
colormap({[000]) “%set the wireframe to black
4 Grid and axes can be turned off by
grid off
axis off
Trang 57
Wireframe and surface Plotting
» The view point (location of the observer) is controlled by
Trang 58
Wireframe and surface Plotting
+ To determine the current viewing geometry , we type
>> [az, el] = view;
» To set the viewpoint to the default values, we type
Trang 59Wireframe and surface Plotting
>>view(-45,60)
Figure (c) shows the result of
>>view(-25,0)
Trang 61
Wireframe and surface Plotting
Sometimes it is desirable to plot a function as a surface instead of as a
wirefram Function surf does this
>> surf (H)
This function produces a plot identical to mesh; To convert the color
to gray, we use the command
Trang 62Wireframe and surface Plotting
Trang 63
Wireframe and suriace Plotting
When the objective is to plot an analytic function of two variables, we
use meshgrid to generate the coordinates and from these we generate the discrete (sampled) matrix to use in mesh or surf For example, to plot
Trang 64Basic Highpass Filtering
Given the transfer function H/, (u,v) of a lowpass filter, we obtain the
transfer function of the corresponding highpass filter by using the simple relation
H,,(u,v)=1-H, (u,v)
function H= hpfilter (type,M,N, DO,n)
% HPFILTER Compute frequency domain highpass
Trang 65
High Frequency Domain Filter
highpass filters <=> lowpass filters
H,,, (u,v) =l—H, u,v)
Trang 66High Frequency Domain Filter
Ideal highpass filter
Butterworth highpass filter =»
Gaussian highpass filter
Trang 67filter H (u,v) = 1 if Dtu,v)>D, :
Trang 68ioe che”
So
—
—
Se See
oS aes
ss cans
sa
So
35 ine Sa om
oS
co
oo one
oo 2S See coe
oS
on een
a
oe Soe ene
on
a
— S5 Tae
Trang 69
High Frequency Domain Filter
Trang 70High Frequency Domain Filter