Frequency Domain Processingstaff.cs.psu.ac.th/sathit/DigitalImage/Frequency Domain... ·...
Transcript of Frequency Domain Processingstaff.cs.psu.ac.th/sathit/DigitalImage/Frequency Domain... ·...
Frequency Domain Processing
Fourier transform offers considerable flexibility in thedesign and implementation of filtering solutions
in areas such as image enhancement, image restoration, image data compression,
and a host of other applications of practical interest.
สัญญาณ (Signal)
A measurable phenomenon that changes over time or throughout space.
01101000101101110110010110001
soundsound imageimage
codecode
Signals: Space‐Time vs. Frequency‐Domain Representation
• Space/time representation: a graph of the measurements with respect to a point in time and/or positions in space
• Fact: signals undulate (otherwise they’d contain no information).
• Frequency-domain representation: an exact description of a signal in terms of its wavelike form.
Origin of Sounds
• กลไกการเคลื่อนที่ของคลื่นเสียงในอากาศ เป็นกลไกของการสัน่(mechanical vibrations)
• Vibrations: internal elastic motions of the material.
• พืน้ผิวของวตัถเุป็นสาเหตใุห้มีการเคลื่อนที่คล้ายกบัลกูคลื่น ที่มีการบีบอดัและการคลายตวัในอากาศ ซึง่จะแพร่ผา่นอากาศจากพืน้ผิว
• วตัถจุะสัน่ตามสภาวแวดล้อม (modes).• mode ทําให้เกิดรูปแบบของการสัน่ที่มีรูปร่างแตกตา่งกนั
– part of the object surface moves out while another part moves in — a standing wave.
รูปแบบการสัน่ในแตล่ะโหมด
displacement from rest position
string modes
internal pressure
pipe modes
สงัเกตวา่โหมดตา่งๆ มีการเคลื่อนที่เป็นรูปไซน์
คลื่นเสียง
string sound
pipe soundThe vibratory modes add up to one complex motion that pushes the air around the vibrating object
The vibratory modes add up to one complex motion that pushes the air around the vibrating object
Even-order harmonicsEven-order harmonics
Odd-order harmonicsOdd-order harmonics
การแทนสญัญาณในโดเมนของความถี่
( ) ( ) ⎥⎦⎤
⎢⎣⎡ +∑
+=
∞
−∞=tn
nt
n122sin
121
λπsq
Odd-order harmonicsOdd-order harmonics
คลื่นที่แทนด้วยสีนํา้เงินเป็น
ผลรวมของการกระเพือ้มของ
square wave ที่แทนด้วยสีดํา
ดงันัน้เมื่อคลื่นมีการสอดแทรก
ด้วยความถึท่ี่ตา่งกนัมากๆเข้าทํา
ให้เกิดเป็น square wave เส้นสีแดง
การแทนสญัญาณในโดเมนของความถี่
คาบของสญัญาณใดๆสามารถแทนได้ด้วยผลรวมของไซน์
( ) ( ) ⎥⎦⎤
⎢⎣⎡ +∑
+=
∞
−∞=tn
nt
n122sin
121
λπsq
สัมประสิทธิ์ของฟูเรียร์
ฟังก์ชนัไชน์เป็นฟังก์ชนัพืน้ฐาน
(Basis function)
การรวมไซน์เข้าด้วยกนัจนกลายเป็น Square wave
1 sine 2 sines 4 sines
8 sines 16 sines 32 sines
การวเิคราะห์ข้อมลูด้วย Fourier Transform
t
V
f
A
f0-f0 3f0 5f0-3f0-5f0
f0
3f0
5f0
ข้อมูลหรือสัญญาณใดๆสามารถแยกองค์ประกอบได้ด้วยการ
แปลง Fourier
คุณสมบตัขิองสัญญาณไซน์
( ) ⎟⎠⎞
⎜⎝⎛ −= φ
λπ tAtf 2sin( ) ⎟
⎠⎞
⎜⎝⎛ −= φ
λπ tAtf 2sin
f (t)
).(radians/sfrequency angular theis/2(Hz).sinusoidtheoffrequencytheis/1
λπλ
).(radians/sfrequency angular theis/2(Hz).sinusoidtheoffrequencytheis/1
λπλ
0
อนุกรมฟูเรียร์
( ) ∑∞
=⎟⎠⎞
⎜⎝⎛+⎟
⎠⎞
⎜⎝⎛+=
10
2sin2cosn
nn tnBtnAAtfλπ
λπ( ) ∑
∞
=⎟⎠⎞
⎜⎝⎛+⎟
⎠⎞
⎜⎝⎛+=
10
2sin2cosn
nn tnBtnAAtfλπ
λπ
( )
( ) 02sin2
02cos2
2/
2/
2/
2/
≥⎮⌡⌠
⎥⎦⎤
⎢⎣⎡
⎟⎠⎞
⎜⎝⎛ −=
≥⎮⌡⌠
⎥⎦⎤
⎢⎣⎡
⎟⎠⎞
⎜⎝⎛ −=
−
−
ndttntfB
ndttntfA
nn
nn
for
for
λ
λ
λ
λ
φλπ
λ
φλπ
λ( )
( ) 02sin2
02cos2
2/
2/
2/
2/
≥⎮⌡⌠
⎥⎦⎤
⎢⎣⎡
⎟⎠⎞
⎜⎝⎛ −=
≥⎮⌡⌠
⎥⎦⎤
⎢⎣⎡
⎟⎠⎞
⎜⎝⎛ −=
−
−
ndttntfB
ndttntfA
nn
nn
for
for
λ
λ
λ
λ
φλπ
λ
φλπ
λ
Fourier coefficients are generated by taking the inner product of the function with the basis.
The representation of a function by its Fourier Series is the sum of sinu-soidal “basis functions” multiplied by coefficients.
The basis functions correspond to modes of vibration.
).()(: tfntf =±ℜ∈∃ λλ that such periodic ).()(: tfntf =±ℜ∈∃ λλ that such periodic
The Fourier series is the decomposition of a λ‐periodic signal into a sum of sinusoids.
อนุกรมฟูเรียร์
The Fourier series can also be written in terms of complex exponentials
( )
∑
∑∑∞
−∞=
⎟⎠⎞
⎜⎝⎛ ++∞
−∞=
+∞
−∞=
⎟⎠⎞
⎜⎝⎛ +⋅+⎟
⎠⎞
⎜⎝⎛ +=
==
nnnnn
n
nn
n
nn
tnCitnC
eCeCtf ntiti
φλπφ
λπ
φλπ
λπ
2sin2cos
22( )
∑
∑∑∞
−∞=
⎟⎠⎞
⎜⎝⎛ ++∞
−∞=
+∞
−∞=
⎟⎠⎞
⎜⎝⎛ +⋅+⎟
⎠⎞
⎜⎝⎛ +=
==
nnnnn
n
nn
n
nn
tnCitnC
eCeCtf ntiti
φλπφ
λπ
φλπ
λπ
2sin2cos
22
( )
( ) dttnitntf
dtetfeCnCn
nn
ni ti
n
⎮⌡⌠
⎥⎦⎤
⎢⎣⎡
⎟⎠⎞
⎜⎝⎛ −⋅−⎟
⎠⎞
⎜⎝⎛ −=
==
−
−
−+ ∫2/
2/
2/
2/
2
2sin2cos1
1
λ
λ
λ
λ
λπ
φ
φλπφ
λπ
λ
λ( )
( ) dttnitntf
dtetfeCnCn
nn
ni ti
n
⎮⌡⌠
⎥⎦⎤
⎢⎣⎡
⎟⎠⎞
⎜⎝⎛ −⋅−⎟
⎠⎞
⎜⎝⎛ −=
==
−
−
−+ ∫2/
2/
2/
2/
2
2sin2cos1
1
λ
λ
λ
λ
λπ
φ
φλπφ
λπ
λ
λ
1−=i 1−=i
ntfntf intergers all for)()( =+ λn
tfntf intergers all for)()( =+ λ
ninn eCC φ+= ninn eCC φ+=
xixe xi sincos ±=± xixe xi sincos ±=±
ความสัมพนัธ์ระหว่างส่วนที่เป็นจาํนวนจริงกับส่วนจนิตภาพ
( ) ( ) ( )∫ ( ) ( )∫
( ) ( ) ( )[ ]∫
( ) ( )∫
( )
⎟⎠⎞
⎜⎝⎛ ++∞
−∞=
+∞
−∞=
++∞
−∞=
+∞
−∞= −
−
∞
−∞= −
−−
∞
−∞= −
∞
−∞= −
∞
−∞= −
∑∑∑
∑
∑
∑
∑∑
===
∫=
=
−−−=
−−−=
nn
n
titiiti n
nn
n
nn
n
nn
tni
n
ni
n
ti
nnnn
nnn
nnn
eCeeCeC
edef
def
dtitf
dtfidtftf
φλπ
λπ
φλπ
λπλ
λ
ηλπ
λ
λ
ηω
λ
λ
λ
λ
λ
λ
ηηλ
ηηλ
ηωηωηωηλ
ηωηωηλ
ηωηωηλ
222
22/
2/
2
2/
2/
2/
2/
2/
2/
2/
2/
1
1
sincos1
sin1cos1( ) ( ) ( )∫ ( ) ( )∫
( ) ( ) ( )[ ]∫
( ) ( )∫
( )
⎟⎠⎞
⎜⎝⎛ ++∞
−∞=
+∞
−∞=
++∞
−∞=
+∞
−∞= −
−
∞
−∞= −
−−
∞
−∞= −
∞
−∞= −
∞
−∞= −
∑∑∑
∑
∑
∑
∑∑
===
∫=
=
−−−=
−−−=
nn
n
titiiti n
nn
n
nn
n
nn
tni
n
ni
n
ti
nnnn
nnn
nnn
eCeeCeC
edef
def
dtitf
dtfidtftf
φλπ
λπ
φλπ
λπλ
λ
ηλπ
λ
λ
ηω
λ
λ
λ
λ
λ
λ
ηηλ
ηηλ
ηωηωηωηλ
ηωηωηλ
ηωηωηλ
222
22/
2/
2
2/
2/
2/
2/
2/
2/
2/
2/
1
1
sincos1
sin1cos1
Then some algebraic manipulations lead to the result.
Then some algebraic manipulations lead to the result.
2n
nπωλ
=เมื่อ
จาํนวนเชิงซ้อนของสัมประสิทธิ์ฟูเรียร์
Cn แทนขนาด นัน่คือ
A=|Cn|, ที่สมัพนัธ์อยู่กบัเฟส, φ , ในแตล่ะสว่นจากสญัญาณ f (t), ที่เป็นสญัญาณไซน์ซึง่มีความถี่
ωn = n / λ.
. where niti eCCeCtf nn
n
nn
φλπ
++∞
−∞=
== ∑2
)(
Real & Imaginary parts
อนกุรมฟเูรียร์ของโคไซน์อนกุรมฟเูรียร์ของโคไซน์
( ) ( ) ( ) ( )[ ]( ) ( ) ( )[ ]λωδλωδ
λωδλωδωNNi
NNFNA
NA
−++−φ+
−++φ=
sincos
2
2ℑ
Real + Imaginary to Magnitude & Phase
The real and imaginary parts at the positive frequency, N/λ ...
The real and imaginary parts at the positive frequency, N/λ ...
… form a magnitude, NA/2, and a phase, φ0.… form a magnitude, NA/2, and a phase, φ0.
←
←
Real + Imaginary to Magnitude & Phase
The real and imaginary parts at the negative frequency, -N/λ ...
The real and imaginary parts at the negative frequency, -N/λ ...
… form a magnitude, NA/2, and a phase, -φ0.… form a magnitude, NA/2, and a phase, -φ0.
→
→
การแปลงฟูเรียร์
( )f t ( )F ω
ℑ
1−ℑ
( ) ( ) ( ) ( )
( ) ( ) ( )[ ]dttittf
dtetfeFF tii
∫ +=
∫==
∞
∞−
∞
∞−
Φ
ωπωπ
ωω ωπω
2sin2cos
2
( ) ( ) ( ) ( )( )
( ) ( ) ( )[ ]
( ) ( )( ) ( )( )[ ] ωωωπωωπω
ωωπωπω
ωωωω ωωπωπ
dtitF
dtitF
deFdeFtf titi
∫ Φ+−Φ+=
∫ −=
∫=∫=
∞
∞−
∞
∞−
∞
∞−
Φ+−∞
∞−
−
2sin2cos
2sin2cos
22
Discrete Fourier Transform
∑=−
=
+1
0
/21 N
k
Nnkikn eh
NH π
∑=−
=
−1
0
/2N
n
Nnkink eHh π
{ }{ }
through 1,,2,1,0 sinusoids, of sum a weighted as sented
-repre be can length finite of ,1,,2,1,0 signal, discrete A/2 −=
−=− NneN
NNkhNnki
k
…
…π
{ }:by given , sinusoid, onto signal original theof projection theas defined
tscoefficien Fourier theare ,1,,2,1,0 set, thewheren
NnHn −= …
The 2‐D Discrete Fourier Transform
• Let f(x, y), for x = 0,1,2, ... , M ‐ 1 and y = 0,1,2, ... , N ‐ 1, denote an M × N image. The 2‐D, discrete Fourier transform (DFT) of f, denoted by F(u, v), is given by the equation
( )1 1
2
0 0( , ) ( , )
M Nj ux M vy N
x yF u v f x y e π
− −− +
= =
= ∑∑for u = 0, 1, 2, ... , M ‐ 1 and v = 0, 1, 2, ... , N ‐ 1. We could expand the exponential into sines and cosines with the variables u and v determining their frequencies (x and y are summed out).
Frequency Domain
• The frequency domain is simply the coordinate system spanned by F(u, v) with u and v as (frequency) variables.
• This is analogous to the spatial domain studied in the previous chapter, which the coordinate system spanned by f(x, y), with x and y as (spatial) variables.
• M X N rectangular region defined by u = 0, 1,2, ... , M ‐ 1 and v = 0, 1,2, ... , N ‐ 1 is often referred to as the frequency rectangle.
• Clearly, frequency rectangle is of the same size as the input image.
จุดบนระนาบฟูเรียร์
The point at column freq. u and row freq. vrepresents a sinusoid with wavelength ω and orientation θ (if R=C=N).
The point at column freq. u and row freq. vrepresents a sinusoid with wavelength ω and orientation θ (if R=C=N).
ω = N/λ, where λ is the wavelength and R=C=N.ω = N/λ, where λ is the wavelength and R=C=N.
Fourier transform
• The inverse, discrete Fourier transform is given by
( )1 1
2
0 0
1( , ) ( , )M N
j ux M vy N
u vf x y F u v e
MNπ
− −+
= =
= ∑∑
for x = 0,1,2, ... , M ‐ 1 and y = 0,1, 2, ... , N ‐ 1.• Thus, given F(u, v), we can obtain f(x, y) back by
means of the inverse DFT. • The values of F(u, v) in this equation sometimes
are referred to as the Fourier coefficients of the expansion.
• The value of the transform at the origin of the frequency domain [i.e.,F(0,0)] is called the dc component of the Fourier transform.
spectrum
• Even if f(x, y) is real, its transform in general is complex.
• The principal method of visually analyzing a transform is to compute its spectrum [i.e., the magnitude of F(u,v)] and display it as an image. Letting R(u, v) and I(u, v) represent the real and imaginary components of F(u, v), the Fourier spectrum is defined as
( )1
2 2 2( , ) ( , ) ( , )F u v R u v I u v= +
The phase angle of the transform is defined as
( ) 1 ( , ), tan( , )
I u vu vR u v
φ − ⎡ ⎤= ⎢ ⎥
⎣ ⎦
power spectrum
The preceding two functions can be used to represent F( u, v) in the familiar polar representation of a complex quantity:
( , )( , ) ( , ) j u vF u v F u v e φ−=
The power spectrum is defined as the square of the magnitude:
( ) ( )
2
2 2
( , ) ( , )
, ,
P u v F u v
R u v I u v
=
= +
For purposes of visualization it typically is immaterial whether we view |F(u,v)| or P(u, v).
conjugate symmetricIf f(x, y) is real, its Fourier transform is conjugate symmetric about the origin; that is,
, ,which implies that the Fourier spectrum also is symmetric about the origin:
, ,It can be shown by direct substitution into the equation for F(u, v) that
F(u,v) = F(u + M,v) = F(u,v + N) = F(u + M,v + N)
In other words, the DFT is infinitely periodic in both the u and v directions, with the periodicity determined by M and N. Periodicity is also a property of the inverse DFT:
f(x,y) = f(x + M,y) = j(x,y + N) = f(x + M,y + N)
• That is, an image obtained by taking the inverse Fourier transform is also infinitely periodic.
• This is a frequent source of confusion because it is not at all intuitive that images resulting from taking the inverse Fourier transform should turn out to be periodic.
• It helps to remember that this is simply a mathematical property of the DFT and its inverse.
Keep in mind also that DFT implementations compute only one period, so we work with arrays of size M x N.
periodicityperiodicityThe periodicity issue becomes important when we consider how DFT data relate to the periods of the transform. • For instance, Fig. 1(a) shows the spectral of a one‐
dimensional transform, F (u). In this case, the periodicity expression becomes F(u) = F(u + M), from which it follows that ; also, because of symmetry,
. • The periodicity property indicate that F (u) has a period of
length M, and the symmetry property indicates that the magnitude of the transform is centered on the origin, as Fig. 1(a) shows.
• This figure and the preceding comments demonstrate that the magnitudes of the transform values from M/2 to M ‐ 1 are repetitions of the values in the half period to the left of the origin.
Fig. 1(a) Fourier spectrum showing back‐to‐back half periods in the interval [0, M ‐1];(b) Centered spectrum in the same interval, obtained by multiplying f(x) by (‐1)x
prior to computing the Fourier transform.
properly ordered• We are interested in obtaining one full, properly ordered period in the interval [0, M ‐ 1].
• It is not difficult to show (Gonzalez and Woods [2002]) that the desired period is obtained by multiplying f(x) by (‐1)x prior to computing the transform.
• Basically, what this does is move the origin of the transform to the point u = M/2, as Fig. 1(b) shows.
• Now, the value of the spectrum at u = 0 in Fig. 1(b) corresponds to F(‐M/2) in Fig. 1(a).
• Similarly, the values at and in Fig. 1(b) correspond to and in Fig. 1(a).
Fig. 2(a) M X N Fourier spectrum (shaded), showing four back‐to‐back quarter periods
contained in the spectrum data. (b) Spectrum obtained by multiplying f(x, y) by 1 prior to computing the
Fourier transform. Only one period is shown shaded because this is the data that would be obtained by an implementation of the equation for F( u, v) .
fast Fourier transform• The DFT and its inverse are obtained in practice using a fast
Fourier transform (FFT) algorithm. • The FFT of an M X N image array f is obtained in the toolbox
with function fft2, which has the simple syntax:F = fft2(f)
• This function returns a Fourier transform that is also of size M X N, with the data arranged in the form shown in Fig. 2(a); that is, with the origin of the data at the top left, and with four quarter periods meeting at the center of the frequency rectangle.
• It is necessary to pad the input image with zero when the Fourier transform is used for filtering. In this case, the syntax become
F = fft2(f, P, Q)With this syntax, fft2 pads the input with the required number of zeros os that the resulting function is of size P X Q.
Fourier spectrum
The Fourier spectrum is obtained by using function abs:
S = abs(F);which computes the magnitude (square root of the sum of the squares of the real and imaginary parts) of each element of the array.• Visual analysis of the spectrum by displaying it as an image is an important aspect of working in the frequency domain. As an illustration, consider the simple image, f, in Fig. 3(a).
(a) white,20x40 (b) imshow(abs(fft2(f),[]) (c) s=log(1+abs(F))
(d) s=fftshift(F);S=log(1+abs(s))
(e) S=log(1+abs(real(s))) (f) S=log(1+abs(imag(s)))
Fig. 3 fft2
Fig. 3(b) shows the result of four bright spots in the corners of the image are due to the periodicity property mentioned in the previous section.
Function fftshift can be used to move the origin of the transform to the center of the frequency rectangle. The syntax is
Fc = fftshift(F);Function fftshift operates by wapping quadrants of F. For example, if
A 1 23 4 , B=fftshift(A);
B 4 32 1 .
When applied to a transform after it has been computed, the net result of using fftshift is the same as if the input image had been multiplied by 1 prior to computing the transform. Note, however, that the two
processes are not interchangeable. That is, Ietting . denote the Fourier transform of the argument, we have that 1 , is equal to fftshift(fft2(f)), but this quantity is notequal to fft2(fftshift (f) ).
inverse Fourier transformFinally. we point out that the inverse Fourier transform is computed using function ifft2, which has the basic syntax
g = ifft2(F);If the input use to compute F is real, the inverse in theory should be real. In practice, however, the output of ifft2 often has very small imaginary components resulting from round‐off errors that are characteristic of floating point computations.• Thus, it is good practice to extract the real part of the result after computing the inverse to obtain an image consisting only of real values. The two operation can be combine
f = real(ifft2(F));
Filtering in the Frequency Domain• Fundamental ConceptsThe foundation for linear filtering in both the spatial and frequency domains is the convolution theorem, which may be written as
, ,
, ,and conversely
, ,
, ,The symbol "*" indicates convolution of the two functions, and the expressions on the sides of the double arrow constitute a Fourier transform pair. For example, the first expression indicates that convolution of two spatial functions can be obtained by computing the inverse Fourier transform of the product of the Fourier transforms of the two functions. Conversely, the forward Fourier transform of the convolution of two spatial functions gives the product of the transforms of the two functions. Similar comments apply to the second expression.
Filtering in the Frequency Domain
• In terms of filtering, we are interested in the first of the two previous expressions. Filtering in the spatial domain consists of convolving an image f(x, y) with a filter mask, h(x, y).
• According to the convolution theorem, we can obtain the same result in the frequency domain by multiplying F(u, v) by H(u, v), the Fourier transform of the spatial filter. It is customary to refer to H (u, v) as filter transfer function.
การกรองด้วย DFT เบือ้งต้น
Preprocessing: determining image size to obtain padding parameters and generating filter H(u,v).
zero‐phase shift filters
• The filter function H(u, v)multiplies both the real and imaginary parts of F(u, v).
• If H (u, v) is real, – then the phase of the result is not changed, a fact that can be seen in the phase equation by noting that,
– if the multipliers of the real and imaginary parts are equal, they cancel out, leaving the phase angle unchanged.
• Filters that operate in this manner are called zero‐phase shift filters.
finite‐impulse‐response (FIR) filter
• It is well known from linear system theory that, under certain mild conditions, inputting an impulse into a linear system completely characterizes the system.
• When working with finite, discrete data as we do in this book, the response of a linear system, including the response to an impulse, also is finite.
• If the linear system is just a spatial filter, then we can completely determine the filter simply by observing its response to an impulse.
• A filter determined in this manner is called a finite‐impulse‐response (FIR) filter.
• All the linear spatial filters in our study are FIR filters.
Filtering in frequency domain
% Obtain the FFT of the padded input
>> F = fft2(f);
% Perform filtering
>> g = real(ifft2(H.*F));
% Crop to original size.
>> imshow(g);
ตวักรองความถี่
• เหตทุี่เรียก H(u,v) วา่ตวักรอง (Filter หรือบางครัง้ก็เรียกวา่ Filter transfer function) เนื่องจาก ฟังก์ชนันีจ้ะกดหรือเข้าไปลดบางความถี่ในขณะที่บางความถี่ไมไ่ด้เข้าไปทําอะไรกบัมนั ผลของการกรองสญัญาณถกูกําหนดโดย
• การคณูของ H กบั F เป็นการคณูแตล่ะจดุภาพ เมื่อ F ได้จากการแปลงฟูเรียร์ ซึง่โดยทัว่ไปจะเป็นจํานวนเชิงซ้อนแต ่H ที่ศกึษากนัในที่นีเ้ป็นจํานวนจริง ในกรณีนีส้มาชิกของ H แตล่ะตวัจะคณูกบั F ทัง้สว่นจริงและสว่นจินตภาพ ดงันัน้จงึเรียก H วา่ตวักรอง zero‐phase‐shift หรือตวักรองที่ไมท่ําให้เฟสของข้อมลูเปลี่ยน
Inverse Fourier Transform: iFT
• ข้อมลูภาพที่ถกูกรองแล้วได้จากการอินเวิร์สการแปลงฟเูรียร์
(Inverse Fourier Transform: iFT)
• iFT โดยทัว่ไปจะเป็นจํานวนเชิงซ้อน
• อยา่งไรก็ตามเมื่อข้อมลูภาพ เป็นจํานวนจริงและตวักรอง
H ก็จะเป็นจํานวนจริง ดงันัน้ผลลพัธ์ที่ได้สว่นจินตภาพควรมีคา่เท่ากบั
ศนูย์ แตใ่นทางปฏิบตัิ iDFT จะมีสว่นจินตภาพติดอยู ่แตเ่ราไมส่นใจ
สว่นนี ้
Obtaining Frequency Domain Filters from Spatial Filters
f(x, y) h(x, y) F(u, v)H(u, v)
h(x, y) H(u, v)โดยที่ เป็นฟังก์ชนัอิมพลัส์
• Using only the properties of the impulse function and the convolution theorem, we have established that filters in the spatial and frequency domains constitute a Fourier transform pair.
• Thus, given a filter in the frequency domain, we can obtain the corresponding filter in the spatial domain by taking the inverse Fourier transform of the former.
ตวักรองเกาส์เซียน (Gaussian Filters)
ฟังก์ชนัเกาส์เซียนมีความสําคญัในการกรองสญัญาณภาพ เนื่องจากรูปร่างของตวักรองงา่ยตอ่การกําหนด ทัง้ในสว่นของการแปลงและการแปลงกลบั เกาส์เซียนเป็นฟังก์ชนัของจํานวนจริง เมื่อกําหนดให้ เป็นตวักรองในโดเมนของความถี่ ฟังก์ชนัตวักรองเกาเซียนสามารถกําหนดได้โดย
⁄
เมื่อ σ เป็นสว่นเบี่ยงเบนมาตรฐาน และตวักรองนีม้ีฟังก์ชนัที่ใช้ในสปาเทียลโดเมนที่สอดคล้องกนัคือ
ตวักรองเกาส์เซียน (Gaussian Filters)
-4 -2 0 2 40
0.2
0.4
0.6
0.8
1Low-Pass:H(u)
u-4 -2 0 2 4
0
0.05
0.1
0.15
0.2
0.25High-Pass:H(u)
u
-4 -2 0 2 40
0.5
1
1.5
2
2.5
3
3.5Low-Pass:h(x)
x-4 -2 0 2 4
-1
-0.5
0
0.5
1High-Pass:h(x)
x
รูปที่ 2 ตวักรองสญัญาณเกาส์เซียนในโดเมนความถี่และเวลาเมื่อ σ=1.5,2
ตวักรองเกาส์เซียน (Gaussian Filters)
ตวักรองทัง้สองโดเมนมีความสําคญัสองอยา่งคือ
1. ทัง้สองสมการสามารถแปลงได้ด้วยฟเูรียร์
2. ทัง้สองฟังก์ชนัมีพฤติกรรมที่ร่วมกนัอยู ่นัน่คือเมื่อ มีฐานที่
กว้างเนื่องจากมีคา่ σ มาก จะมีฐานที่แคบ ซึง่จะเป็นสว่น
กลบัตอ่กนั และจากข้อเท็จจริงที่ σ มีคา่มากๆจนเป็นคา่อนนัต์
จะมีแนวโน้มเป็นฟังก์ชนัของคา่คงที่ สว่น ก็จะมี
แนวโน้มเป็นอิมพลัส์
Low-pass filter High-pass filter
Low-Pass High-Pass
Smoothing Frequency‐Domain Filters
• ขอบและการเปลี่ยนแปลงที่เกิดขึน้ในข้อมลูภาพเกรย์ จะเป็นสญัญาณความถี่สงู ซึง่สามารถตรวจจบัได้ด้วยการแปลงฟเูรียร์ การเกรี่ยหรือการเบรอ (Smoothing or Blurring) ข้อมลูสามารถทําได้ในโดเมนความถี่ โดยการลดทอนสญัญาณในบางชว่งที่เป็นความถี่สงู แบบจําลองในการกรองของโดเมนความถี่สามารถกําหนดได้โดย
• เมื่อ ได้จากการแปลงฟเูรียร์ของข้อมลูภาพเพื่อลดทอนสญัญาณความถี่สงูด้วยการเลือกฟังก์ชนัการแปลงตวักรอง ในหวัข้อนีจ้ะพิจารณาการกรองสญัญาณความถี่ตํ่าผา่น (Lowpass filters) สามชนิดด้วยกนัคือ ตวักรองอดุมคต ิตวักรองบตัเตอร์เวริ์ธ (Butterworth) และตวักรองเกาส์เซี่ยน
ตวักรองความถี่ตํ่าผ่านในอุดมคติ
• ตวักรองความถี่ตํ่าผา่นอยา่งงา่ยที่สดุคือ “cuts off” หรือการเอาองค์ประกอบของสญัญาณความถี่จากการแปลงฟเูรียร์ออก นัน่คือถ้าคา่มากกวา่ D0 จากจดุกําเนิดของการแปลง ซึง่มีฟังก์ชนัการแปลงของ ILPF ดงันี ้
ถ้า
ถ้า• โดยที่ ≥ 0 และ เป็นระยะทางจากจดุ เมื่อเทียบ
กบัจดุศนูย์กลางของตวักรอง เมื่อข้อมลูภาพมีขนาด จดุศนูย์กลางจะอยูท่ี่ ดงันัน้ระยะทางจากจดุ
ใดๆเมื่อเทียบกบัจดุศนูย์กลางของการแปลงฟเูรียร์คือ
ตวักรองสญัญาณอดุมคตจิะให้ความถี่ที่อยูใ่นวงกลมรัศมี ผา่นโดยไมม่ีการลดทอนสญัญาณแตป่ระการใด ในขณะที่ความถี่ที่อยูน่อกวงกลมนีจ้ะถกู
ลดทอนสญัญาณลง สมาชิกในตวักรองนีจ้ะมี cutoff frequency คือ
Original
D0=[5 15 30 80 230]
Original
Butterworth Lowpass Filters
The transfer function of a Butterworth lowpassfilter (BLPF) of order n. and with cutoff frequency at a distance from the origin is defined as
where is given by ILPF.
A perspective plot, image display, and facial cross sections of the BLPF function are shown in below.
020
40
0
20
400
0.5
1
0 50 100 1500
0.2
0.4
0.6
0.8
1
D0=30
(a) Perspective plot of a Butterworth lowpass filter transfer function. (b) Filter displayed as an image. (c) Filter radial cross sections of orders 1 through 5,(reverse) .
Original
Fig. 4.14
Gaussian Lowpass Filters, ⁄
D(u, v) is the distance from the origin of the Fourier transform, which we assume has been shifted to the center of the frequency rectangle.• We did not use a constant in front of the filter to be consistent with all the other filters discussed in the present section, which have a value of 1 at the origin.
• is a measure of the spread of the Gaussian curve. • By letting , we can express the filter in a more familiar form in terms of the notation in this section:
, ⁄
• where is the cutoff frequency. When D(u, v) = , the filter is down to 0.607 of its maximum value.
0 50 100 1500
0.2
0.4
0.6
0.8
1
(Fig4_17) (a) subplot(1,3,1), mesh(Hc(1:5:end,1:5:end));(b) subplot(1,3,2),imshow(Hc);(c) D0 = [10 20 40 100 M], respectively.
Original
(Fig4_17) D0= [10 20 40 100 M];
การประยกุต์ตวักรองความถี่ตํ่าการประยกุต์ตวักรองความถี่ตํ่า
ในรูปนีแ้สดงการใช้ตวักรองความถี่ตํ่า GLPF ที่ช่วยปรับเรสโซลชูนัของภาพให้ดีขึน้ เช่นในกรณีของการสง่แฟ็กซ์ จะเห็น
วา่ตวัอกัษรในภาพแตก ขอบไมเ่รียบ เมื่อนําภาพ (a) มาปรับปรุงด้วยตวักรอง GLPF ที่ D0=40 ดงัแสดงให้รูป (b)
(a)
(b)
การประยกุต์ตวักรองความถี่ตํ่าในสิง่พิมพ์การประยกุต์ตวักรองความถี่ตํ่าในสิง่พิมพ์
ภาพเดิม (732x785)
GLPF, D0=100
GLPF, D0=80
การประยกุต์ตวักรองความถี่ตํ่ากบัภาพถ่ายดาวเทียม
Sharpening Frequency Domain Filters
Edges and other abrupt changes in gray levels are associated with high‐frequency components, image sharpening can be achieved in the frequency domain by a highpass filtering process, which attenuates the low‐frequency component's without disturbing high‐frequency information in the Fourier transtion.• The transfer function of the high pass filters discussed in this section can be obtained using the relation
ตวักรองสญัญาณความถี่สูงผา่น
0.2
0.4
0.6
0.8
Original High-pass gaussian
High-pass btw High-pass ideal
D0=5%, n=2(fig4_19)
Original Highpass Butterworth
Boost,H=0.5+2Hbw HistogramEq of Boost