chapter_4

advertisement
Chapter 4
Image Enhancement in the
Frequency Domain
國立雲林科技大學 電子工程系
張傳育(Chuan-Yu Chang ) 博士
Office: ES 709
TEL: 05-5342601 ext. 4337
E-mail: chuanyu@yuntech.edu.tw
Background

Fourier series:

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 transform

Even functions that are not periodic
can be integral of sines and/or cosine
multiplied by a weighting function.
A function expressed in either a Fourier
series or transform, can be reconstructed
completely via an inverse process, with no
loss of information.

2
The 1D Fourier Transform

Fourier Transform Pair
(4.2-1) and (4.2-2)
The Fourier transform, F(u), of a single variable, continuous
function, f(x), is defined as

F (u)   f ( x)e j 2ux dx
(4.2-1)


We can obtain f(x) by means of the inverse Fourier
transform

f ( x)   F (u )e j 2ux du


Extended to two variables, u and v.


 
f ( x, y )   
F (u, v) 
 
 
 
(4.2-2)
A function can be recovered
from its transform.
f ( x, y )e  j 2 (ux  vy) dxdy
F (u, v)e j 2 (ux  vy) dudv
(4.2-3)
(4.2-4)
3
The 1D Fourier Transform (cont.)

Discrete Fourier Transform, DFT
DFT:
1
F (u ) 
M
M 1
 f ( x )e
f ( x) 
,
u  0,1,2,..., M  1
x 0
M 1
IDFT:
 j 2ux / m
 F (u)e
j 2ux / m
,
在離散FT時,乘數所放
的位置並不重要,可放
在轉換前或轉換後,或
者兩個都放,但須滿足
(4.2-5)
其乘積為1/M
x  0,1,2,..., M  1
x 0

The concept of the frequency domain follows directly
from Euler’s Formula
(4.2-7)
j
e

(4.2-6)
 cos  j sin
Substituting (4.2-7) into (4.2-5) obtain
1
F (u) 
M
M 1
 f ( x)cos2ux / M  j sin2ux / M 
x 0
Each term of the Fourier Transform is
composed of the sum of all values of the
function f(x).
(4.2-8)
每一分項稱為頻率成分(frequency
component)
4
The 1D Fourier Transform (cont.)

Glass prism


The prism is a physical device that separates light
into various color components, each depending
on its wavelength content.
The Fourier transform


The FT may be viewed as a “mathematical prism”
that separates a function into various components,
based on frequency content.
The Fourier transform lets us characterize a
function by its frequency content.
5
The 1D Fourier Transform (cont.)

As in the analysis of complex numbers, we
find it convenient sometimes to express
F(u) in polar coordinates
F (u )  F (u ) e  j (u )
Rear part of F(u)
imaginary part of F(u)
where
F (u )  R 2 (u )  I 2 (u )
 I (u ) 

 R (u ) 
 (u )  tan 1 
(magnitude, spectrum)
(phase angle, phase spectrum)
2
P (u )  F (u )  R 2 (u )  I 2 (u )
(power spectrum, spectral density)
6
Example 4.1: Fourier spectra of two simple 1-D function


在x域曲線下的面積加倍時,頻譜上的高度也會加倍。(The height
of the spectrum doubled as the area under the curve in the xdomain doubled.)
當函數長度加倍時,在相同區間上頻譜的零點加倍。(The number
of zeros in the spectrum in the same interval doubled as the
length of the function doubled)
A=1,K=8,M
=1024
7
The 1D Fourier Transform (cont.)

處理離散變數時,可以下式表示函數f(x)
f ( x)  f ( x0  xx)

同理,因為頻率總是由零頻率開始,因此F(u)
F (u)  F (uu)

(4.2-13)
(4.2-14)
Fig. 4.2顯示,f(x)和F(u)成倒數關係
1
u 
Mx
(4.2-15)
8
The 1D Fourier Transform (cont.)



In the discrete transform of Eq(4.2-5), the function f(x) for x=0, 1,
2,…,M-1, represents M samples from its continuous counterpart.
These samples are not necessarily always taken at integer
values of x in the interval [0, M-1]. They are taken at equally
spaced.
Let x0 denote the first point in the sequence. The first value of the
sampled function is f(x0). The next sample has taken a fixed
interval x units away to give f(x0+x). The k-th sample is
f(x0+kx).
f ( x)  f ( x0  xx)

The sequence always starts at true zero frequency. Thus the
sequence for the values of u is 0, u, 2u,…,[M-1]u. The F(u)
F (u)  F (uu)

(4.2-13)
(4.2-14)
x and u are inversely related by the expression (in Fig. 4.2)
1
u 
Mx
(4.2-15)
9
The 2D DFT and Its Inverse

2D DFT pair
1
F (u, v) 
MN
M 1 N 1
 f ( x, y)e
(4.2-16)
x 0 y 0
M 1 N 1
f ( x, y ) 
 j 2 (ux / M  vy / N )
 F (u, v)e
j 2 (ux / M  vy / N )
(4.2-17)
u 0 v 0
2D Fourier spectrum, phase angle, power spectrum
(4.2-18)
F (u , v)  R 2 ( x, y )  I 2 ( x, y )
(4.2-19)
1 
I (u , v) 
 (u , v)  tan 

 R (u , v) 
2
P (u , v)  F (u , v)  R (u , v)  I (u , v)
2
(4.2-20)
2
10
The 2D DFT and Its Inverse

It is common practice to multiply the input
image function by (-1)x+y prior to computing
the Fourier transform.


 f ( x, y)(1) x y  F (u  M / 2, v  N / 2)
(4.2-21)
Shifts the origin of F(u,v) to frequency coordinates(M/2,N/2),
which is the center of the MxN area occupied by the 2-D DFT.
This area of the frequency domain is called
Frequency rectangle
11
The 2D DFT and Its Inverse (cont.)

The value of the transform at (u,v)= (0,0) is
1 M 1 N 1
F (0,0) 
f ( x, y)

MN x 0 y 0


(4.2-22)
F(0,0) sometimes is called the dc component of the
spectrum.
If f(x,y) is real, its Fourier transform is conjugate symmetric
F (u, v)  F * (u,v)
F (u, v)  F (u,v)
1
u 
M x
1
v 
N y
(4.2-23)
The spectrum of the
Fourier transform is
symmetric.
(4.2-24)
(4.2-25)
(4.2-26)
12
Example 4.2:
Centered spectrum of a simple 2-D function
The image was processed prior
to displaying by using the log
transformation in Eq.(3.2-2)
White rectangle of
size 20x40 pixels
The image was multiplied by (-1)x+y
prior to computing the Fourier
transform
13
Filtering in the Frequency domain

Some basic properties of the frequency domain




Frequency is directly related to rate of change.
The slowest varying frequency component (u=v=0)
correspond to the average gray level of an image.
As we move away from the origin of the transform, the low
frequencies correspond to the slowly varying components
of an image.
As we move further away from the origin of the transform,
the higher frequencies correspond to the faster and faster
gray level changes in the image.
14
Example 4.3
An image and its Fourier spectrum
15
Filtering in the Frequency domain (cont.)

In spatial domain


g(x,y)=h(x,y)*f(x,y)
In frequency domain


H(u,v) is called a filter.
The Fourier transform of the output image is


The multiplication of H and F
involves two-dimensional
functions and is defined on an
element-by-element basis.
G(u,v)=H(u,v)F(u,v)
The filtered image is obtained simply by taking the
inverse Fourier transform of G(u,v)

Filtered Image=F-1[G(u,v)]
16
Filtering in the Frequency domain (cont.)
Basics of filtering in the frequency domain
1.
2.
3.
4.
5.
6.
Multiply the input image by (-1)x+y to center the transform
Compute F(u,v), the DFT of the image from (1)
Multiply F(u,v) by a filter function H(u,v)
Compute the inverse DFT of the result in (3)
Obtain the real part of the result in (4)
Multiply the result in (5) by (-1)x+y
17
Filtering in the Frequency domain (cont.)

Basic steps for filtering in the frequency domain
18
Some basis filters and their properties

Notch filter

It is a constant function with a hole at the origin.
0 if u, v   M / 2, N / 2
H u, v   
otherwise
1

Set F(0,0) to zero and leave all other frequency components
of the Fourier transform untouched.
19
Example

Result of filtering the image in Fig. 4.4(a) with a notch filter that
set to 0 the F(0,0) term in the Fourier transform.
 In reality the average of the displayed image cannot be zero
because the image has to have negative values for its average
gray level to be zero and displays cannot handle negative
quantities.
 The most negative value was set to zero, and other values scaled
up from that.
20
Some basis filters and their properties




Low frequencies in Fourier transform are responsible for the
general gray-level appearance of an image over smooth areas.
High frequencies are responsible for detail, such as edges and
noise.
A filter that attenuates high frequencies while passing low
frequencies is called a low pass filter.
 A lowpass-filtered image has less sharp detail than original image.
A filter that has the opposite characteristic is called a high pass
filter.
 A highpass-filtered image has less gray level variations in smooth
areas and emphasized transitional gray-level detail.
 Such an image will appear sharper.
21
The effects of lowpass and highpass filtering
Blurred image
Lowpass
Highpass
Sharp image with
little smooth gray
level detail because
the F(0,0) has been
set to zero.
22
Example

Result of highpass filtering the image in Fig.
4.4(a)
The highpass filter is modified by adding a
constant of one-half the filter height to the
filter function
23
Correspondence between Filtering in the
Spatial and Frequency Domains

Convolution theorem
M 1 N 1

1
f ( x, y) * h( x, y) 
f (m, n)h( x  m, y  n)
MN m0 n0
(4.2-30)
1. Flipping one function about the origin.
2. Shifting that function with respect to the other by changing
the values of (x,y)
3. Computing a sum of products over all values of m and n,
for each displacement (x,y).
24
Correspondence between Filtering in the Spatial
and Frequency Domains (cont.)

Used to indicate that the expression on
the left can be obtained by taking the
IFT of the expression on the right.
(4.2-31)
Fourier transform pair
f ( x, y)  h( x, y)  F (u, v) H (u, v)
f ( x, y)h( x, y)  F (u, v) * H (u, v)

(4.2-32)
Impulse function of strength A
M 1 N 1
 s( x, y) A x  x , y  y   Asx , y 
x 0 y 0
0
0
0
0
(4.2-33)
M 1 N 1
 s( x, y) x, y   s0,0
(位於原點的單位脈衝) (4.2-34)
x 0 y 0
25
Correspondence between Filtering in the Spatial
and Frequency Domains (cont.)

The Fourier transform of a unit impulse at the origin
1
F (u, v) 
MN


M 1 N 1
  ( x, y)e
 j 2 ( ux / M  vy / N )
x 0 y 0
(4.2-35)
1
MN
Let f(x,y)=(x,y), Eq.(4.2-30) and (4.2-34)
1 M 1 N 1
f ( x, y ) * h ( x , y ) 
 (m, n)h( x  m, y  n)

MN m 0 n 0
1

h ( x, y )
MN
(4.2-36)
26
Correspondence between Filtering in the Spatial
and Frequency Domains (cont.)

Based on (4.2-31), combining (4.2-35) and (4.2-36)
f ( x, y )  h( x, y)  F (u, v) H (u, v)
 ( x, y)  h( x, y)   ( x, y)H (u, v)
h( x, y)  H (u, v)


(4.2-37)
Given a filter in the frequency domain, we can obtain the
corresponding filter in the spatial domain by taking the
IFT of the former.
We can specify filters in the frequency domain, take their
inverse transform, and then use the resulting filter in the
spatial domain as a guide for constructing smaller spatial
filter masks.
27
Introduction to the Fourier Transform and
the Frequency Domain (cont.)

高斯濾波器(Gaussian Filter)
u 2 / 2 2
H (u)  Ae

The corresponding filter in the spatial domain
2 2 2 x 2
h( x)  2 Ae

These two equations represent an important result for two
reasons:


They constitute a Fourier transform pair, both components of
which are Gaussian and real. (上述二式構成Fourier transform
pair,兩個成分均為高斯且為實數。)
These functions behave reciprocally with respect to one
another. (這些函數彼此互為倒數。)

當H(u)有較大範圍的剖面時,h(x)有較窄的剖面。
28
Introduction to the Fourier Transform and
the Frequency Domain (cont.)

We can construct a highpass filter as a difference of
Gaussians, as follows:
u 2 / 2 12
H (u)  Ae


u 2 / 2 2 2
 Be
With A>=B and 1>2.
The corresponding filter in the spatial domain is
2 212 x 2
h( x)  2 1 Ae
2 2 2 2 x 2
 2  2 Ae
29
Introduction to the Fourier Transform and
the Frequency Domain (cont.)
Once the values turn
negative, they never
turn positive again.
We can implement
lowpass filtering in the
spatial domain by
using a mask with all
positive coefficients.
30
Smoothing Frequency-Domain Filters

Ideal Low-pass Filter

2 D ideal lowpass filter

Cuts off all high frequency components of the FT that are at a
distance greater than a specified distance D0 from the origin of
the transform.
從點(u,v)到傅立葉轉換
中心點的距離
1
H (u, v)  
0
if D(u, v)  D0
(4.3-2)
if D(u, v)  D0
D(u, v)  (u  M / 2)  (v  N / 2)
2
2
(4.3-3)
31
Smoothing Frequency-Domain Filters (cont.)

截止頻率(cutoff frequency)


H(u,v)=1和H(u,v)=0之間的過渡點。
整體功率(total image power)

Summing the components of the power spectrum at each
point (u,v).
M 1 N 1
PT   P(u, v)
(4.3-4)
u 0 v 0

百分比功率(% of the power)


  100 P(u, v) / PT 

u
v

(4.3-5)
32
Example 4.4 Image power as a function of
distance from the origin of the DFT
半徑為5, 15, 30,
80, and 230
功率比為92,
94.6, 96.4, 98,
and 99.5
33
Example 4.4 Image power as a function of
distance from the origin of the DFT
(cont.)
存在振鈴現象
(ringing)
34
Smoothing Frequency-Domain Filters (cont.)
35
Smoothing Frequency-Domain Filters (cont.)

巴特沃斯特低通濾波器(Butterworth Lowpass Filter)


1
H (u, v) 
2n
1  D(u, v) / D0 
BLPF transfer function does not have a sharp
discontinuity (BLPF沒有銳利不連續的截止頻率)
Defining a cutoff frequency locus at points for which H(u,v)
is down to a certain fraction of its maximum value. (將截
止頻率定義在H(u,v)降到最大值的某個比例時。)
36
Smoothing Frequency-Domain Filters (cont.)



一階的BLPF沒有振鈴也
沒有負值。
二階的BLPF有輕微的振
鈴,有小負值。
高階的BLPF有明顯的振
鈴,
37
Smoothing Frequency-Domain Filters (cont.)



The BLPF of order 1 has neither ringing nor negative values.
The filter of order 2 does show mild ringing and small negative
values, but they certainly are less obvious than in the ILPF.
Ringing in the BLPF becomes significant for higher-order filter.
38
Smoothing Frequency-Domain Filters (cont.)

高斯低通濾波器(Gaussian Lowpass Filters)
H (u, v)  e

 D2 u,v / 2 2
Let =D0,
H (u, v)  e

 D2 u ,v / 2 D0 2
where D0 is the cutoff frequency.
39
Smoothing Frequency-Domain Filters (cont.)

Example 4.6: Gaussian
lowpass filtering


A smooth transition in
blurring as a function of
increasing cutoff
frequency.
No ringing in the GLPF.
40
Smoothing Frequency-Domain Filters (cont.)

A sample of text of poor resolution

Using a Gaussian lowpass filter with
41
Smoothing Frequency-Domain Filters (cont.)

A sample of text of poor resolution

Using a Gaussian lowpass filter with D0=80 to repair the
text.
42
Smoothing Frequency-Domain Filters (cont.)

Cosmetric processing


Appling the lowpass filter to produce a smoother, softer-looking result from a sharp
original.
For human faces, the typical objective is to reduce the sharpness of fine skin lines and
small blemishes.
43
Smoothing Frequency-Domain Filters (cont.)

(a) High resolution radiometer image showing part of the Gulf
of Mexico (dark) and Folorida (light).



Existing many horizontal sensor scan lines.
(b) After Gaussian lowpass filter with D0=30.
(c) After Gaussian lowpass filter with D0=10.

The objective is to blur out as much detail as possible while
leaving large features recognizable.
44
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.


Attenuating the low frequency components without
disturbing high-frequency information in the Fourier
transform.
The transform function of the highpass filters can be
obtained using the relation
H hp u, v   1  H lp u, v 
45
Sharpening Frequency Domain Filters

理想高通濾波器(Ideal Highpass Filters)
0
H (u, v)  
1

if D(u , v)  D0
(4.4-2)
巴特沃斯高通濾波器(Butterworth Highpass Filters)
H (u, v) 

if D(u, v)  D0
1
2n
1  D0 / D(u, v)
(4.4-3)
高斯高通濾波器 (Gaussian Highpass Filters)
H (u, v)  1  e
 D2 u ,v / 2 D02
(4.4-4)
46
Sharpening Frequency Domain Filters (cont.)
It set to zero all frequencies inside
a circle of radius D0 while passing
without attenuation, all frequencies
outside the circle.
The IHPF is not physically
realizable with electronic
components, but it can be
implemented in a computer.
47
Sharpening Frequency Domain Filters (cont.)

Spatial representations of typical (a) ideal (b)
Butterworth, and (c) Gaussian frequency domain
highpass filters
48
Sharpening Frequency Domain Filters (cont.)

Result of ideal highpass filtering (a) with D0=15,
30, and 80

IHPFs have ringing properties.
49
Sharpening Frequency Domain Filters (cont.)

Result of BHPF order 2 highpass filtering (a) with
D0=15, 30, and 80
50
Sharpening Frequency Domain Filters (cont.)

Result of GHPF order 2 highpass filtering (a) with
D0=15, 30, and 80
51
Sharpening Frequency Domain Filters (cont.)

The Laplacian in the Frequency Domain

It can be shown that
 d n f x 
n




ju
F u 

n
dx



Extended to two dimension
Laplacian

(4.4-5)
  2 f  x, y   2 f  x, y  
2
2









ju
F
u
,
v

jv
F u , v 

2
2
y
 x

  u 2  v 2 F u, v 


(4.4-6)
According to Eq.(3.7-1), the expression inside the brackets
on the left side of Eq.(4.4-6) is recognized as the Laplacian
of f(x,y). Thus, we have

 

 2 f x, y    u 2  v 2 F u, v
(4.4-7)
52
Sharpening Frequency Domain Filters (cont.)

Eq(4.4-7) presents that the Laplacian can be implemented in the
frequency domain by using the filter

H (u, v)   u 2  v 2




(4.4-8)
Assume that the origin of F(u,v) has been centered by performing
the operation f(x,y)(-1)x+y prior to taking the transform of the image.
If f are of size MxN, this operation shifts the center transform so
that (u,v)=(0,0) is at point (M/2, N/2) in the frequency rectangle.
The center of the filter function needs to be shifted:

H (u, v)   (u  M / 2)2  (v  N / 2)2


(4.4-9)
The Laplacian filtered image in the spatial domain is obtained by
computing the inverse Fourier transform of H(u,v)F(u,v)
 f x, y   
2
1
 u  M / 2  v  N / 2 F (u, v)
2
2
(4.4-10)
53
Sharpening Frequency Domain Filters (cont.)

Computing the Laplacian in the spatial domain using
Eq(3.7-1) and computing the Fourier transform of
the result is equivalent to multiplying F(u,v) by H(u,v).


2 f x, y    u  M / 22  v  N / 22 F u, v

(4.4-11)
The spatial domain Laplacian filter function obtained
by taking the inverse Fourier transform of Eq(4.49)
has some properties:


The function is centered at (M/2, N/2), its value at the top of
the dome is zero.
All other values are negative.
54
Sharpening Frequency Domain Filters (cont.)
55
Sharpening Frequency Domain Filters (cont.)

We form an enhanced image g(x,y) by subtracting the
Laplacian from the original image
g ( x, y)  f ( x, y)  2 f ( x, y)

(4.4-12)
在頻率域,也有類似的效果


g ( x, y)  1 1  u  M / 2  v  N / 2 F (u, v)
2
2
(4.4-13)
56
Sharpening Frequency Domain Filters (cont.)

在空間域,可將原始影像減去Laplacian來形成一幅增強後的
影像
g ( x, y)  f ( x, y)  2 f ( x, y)

(4.4-12)
在頻率域,也有類似的效果


g ( x, y)  1 1  u  M / 2  v  N / 2 F (u, v)
2
2
(4.4-13)
57
Sharpening Frequency Domain Filters (cont.)
58
Unsharp masking, high-boost filtering

鈍化遮罩 (unsharp masking)


藉由減去影像自己的模糊化版本,所得到的銳化影像
藉由減去影像自己的低通濾波版本,以獲得高通濾波影像
f hp ( x, y)  f ( x, y)  f lp ( x, y)

High-boot filtering multiplying f(x,y) by a constant A>=1.
f hb ( x, y)  Af ( x, y)  f lp ( x, y)

(4.4-15)
(4.4-15)可改寫成
f hb ( x, y)  ( A 1) f ( x, y)  f ( x, y)  f lp ( x, y)

(4.4-14)
(4.4-16)
將(4.4-14)代入,可得
f hb ( x, y)  ( A 1) f ( x, y)  f hp ( x, y)
(4.4-17)
59
Unsharp masking, high-boost filtering (cont.)
 Fhp (u, v)  F (u, v)  Flp (u, v)
Flp (u, v)  H lp (u, v) F (u, v)
 Fhp (u, v)  F (u, v)  H lp (u, v) F (u, v)

 F (u, v) 1  H lp (u, v)


從上式的推導,鈍化遮罩可使用下列的複合濾波器直接在頻
率域上實現
H hp (u, v)  1  H lp (u, v)

(4.4-18)
所以,high-boot filtering可以下列複合濾波器在頻率域上實現
Hhb (u, v)  ( A 1)  Hhp (u, v)
(4.4-19)
60
Sharpening Frequency Domain Filters (cont.)
61
Sharpening Frequency Domain Filters (cont.)
62
Homomorphic filter






Improving the appearance of an image by simultaneous gray-level
range compression and contrast enhancement.
An image f(x,y) can be expressed as the product of illumination and
reflectance components:
(4.5-1)
f ( x, y)  i( x, y)r ( x, y)
Eq (4.5-1) cannot be used directly to operate separately on the
frequency components of illumination and reflectance because the
Fourier transform of the product of two functions is not separable
 f ( x, y)  ix, y r x, y 
However, we define
zx, y   ln f x, y 
Then
or
 ln ix, y   ln r x, y 
z ( x, y)  ln f x, y 
 ln ix, y  ln r x, y 
Z u, v   Fi u, v   Fr u, v 
(4.5-2)
(4.5-3)
(4.5-4)
63
Homomorphic filter

If we process Z(u,v) by means of a filter function H(u,v) then
from Eq.(4.2-27)
S u , v   H u , v Z u , v 
 H u , v Fi u, v   H u , v Fr u , v 

In spatial domain,
sx, y   1S u, v 

By letting
 1H u, v Fi u, v  1H u, v Fr u, v 
i ' x, y   1H u, v Fi u, v

(4.5-6)
(4.5-7)
and
r ' x, y   1H u, v Fr u, v 

(4.5-5)
(4.5-8)
Eq. (4.5-6) can be expressed in the form
sx, y   i ' x, y   r ' x, y 
(4.5-9)
64
Homomorphic filter (cont.)

Since z(x,y) was formed by taking the logarithm of the original
image f(x,y), the inverse operation yields the desired enhanced
image, denoted by g(x,y)
g  x, y   e s  x , y 
 e i '( x, y ) e r '( x, y )
(4.5-10)
 i0 ( x, y )r0 ( x, y )


Where
i0 ( x, y)  e i '( x, y )
(4.5-11)
r0 ( x, y)  e r '( x, y )
(4.5-12)
The key to the approach is the separation of the illumination and
reflectance components. The homomorphic filter function H(u,v)
can then operate on these components separately.
65
Homomorphic filter (cont.)

Homomorphic filtering approach for image
enhancement

The illumination component of an image generally is
characterized by slow spatial variations, while the
reflectance component tends to vary abruptly .

Associating the low frequencies of the Fourier transform of
the logarithm of an image with illumination and the high
frequencies with reflectance.
66
Homomorphic filter (cont.)


The HF requires specification of a filter function H(u,v) that
affects the low-and high frequency component of the Fourier
transform in different ways.
The filter tends to decrease the contribution made by the low
frequencies (illumination) and amplify the contribution made by
high frequencies (reflectance).
 The net result is simultaneous dynamic range compression and
contrast enhancement.
2
2
H u, v    H   L 1  e c D u ,v / D0     L


rH>1
rL<1
抑制低頻(照明),並放大高頻(反射)
,增加影像的對比度 67
Example: 4.10

In the original image
 The details inside the shelter are obscured by the glare from the
outside walls.
 Fig. (b) shows the result of processing by homomorphic filtering,
with L=0.5 and H=2.0.
 A reduction of dynamic range in the brightness, together with an
increase in contrast, brought out the details of objects inside the
shelter.
68
Implementation

Some additional properties of the 2D Fourier
Transform

Translation properties:
f x, y e j 2 u0 x / M v0 y / N   F u  u0 , v  v0 
f x  x0 , y  y0   F u, ve j 2 ux0 / M vy0 / N 
(4.6-1)
(4.6-2)
when u0=M/2, v0=N/2
e j 2 u0 x / M v0 y / N   e j x y   1x y
Eq(4.6-1) becomes
f x, y 1x y  F u  M / 2, v  N / 2
(4.6-3)
f x  M / 2, y  N / 2  F u, v 1u v 
(4.6-4)
Same as Eq(4.2-21), which we used for centering the transform.
69
Implementation (cont.)

Distributivity


The Fourier transform is distributive over addition, but not
over multiplication
 f1 x, y   f 2 x, y    f1 x, y    f 2 x, y 
(4.6-5)
 f1 x, y   f 2 x, y    f1 x, y   f 2 x, y 
(4.6-6)
Scaling
af x, y   aFu, v 
1
f ax, by 
F u / a, v / b 
ab
(4.6-7)
(4.6-8)
70
Implementation (cont.)

Rotation




If we introduce the polar coordinates
x=r cos , y=r sin , u=w cos j, v= w sin j
then f(x,y) and F(u,v) become f(, ) and F(w, j)
Direct substitution into the definition of the Fourier transform
yields
f r ,   0   F w , j   0 

(4.6-9)
The expression indicates that rotating f(x,y) by an angle 0
rotates F(u,v) by the same angle.
71
Implementation (cont.)

Periodicity symmetry
F u, v   F u  M , v   F u, v  N   F u  M , v  N 
f x, y   f x  M , y   f x, y  N   f x  M , y  N 

Conjugate symmetry
F u, v   F *  u,v 
F u, v   F  u,v 
72
Implementation (cont.)
週期性表示F(u)有一長度為M的週期
共軛對稱性表示頻譜的中心位於原點
73
Implementation (cont.)

Separability

The discrete Fourier transform in Eq(4.2-16) can be
expressed in the separable form
1
F u, v  
M
1

M
M 1
e
x 0
 j 2ux / M
1
N
N 1
 f x, y e  j 2vy / n
y 0
(4.6-14)
M 1
 F x, v e  j 2ux / M
x 0
where
1
F  x, v  
N
N 1
 f x, y e  j 2vy / n
(4.6-15)
y 0
74
Implementation (cont.)

Computing the inverse Fourier Transform Using a
forward transform algorithm


2D Fourier transforms can be computed via the application
of 1-D transforms.
The 1-D Fourier transform pair was defined as
1
F (u ) 
M
f ( x) 
M 1
 f ( x)e  j 2ux / M ,
u  0,1,2,..., M  1
(4.6-16)
x 0
M 1
j 2ux / M
F
(
u
)
e
,

x  0,1,2,..., M  1
(4.6-17)
x 0

Taking the complex conjugate of Eq(4.6-17) and dividing
both sides by M yields
1
1
f * ( x) 
M
M
M 1
 F * (u )e j 2ux / M ,
x  0,1,2,..., M  1
(4.6-18)
x 0
Both (4.6-16) and (4.6-18) have same form
75
Implementation (cont.)



Inputing F*(u) into an algorithm designed to
compute the forward transform gives the quantity
f*(x)/M.
Taking the complex conjugate and multiplying by M
yields the desired inverse f(x).
A similar analysis for two variables yields:
1
1 M 1 N 1
f * ( x, y ) 
F * (u, v)e j 2 (ux / M  vy / N )


MN
MN x 0 y 0
(4.6-19)
76
Implementation (cont.)

More on periodicity: the need for padding


Based on the convolution theorem, multiplication in the
frequency domain is equivalent to convolution in the spatial
domain, and vice versa.
Periodicity is part of the process, and it cannot be ignored.
1
f ( x ) * h( x ) 
M
M 1
 f (m)h( x  m)
(4.6-20)
m 0
77
Each function consists of 400 points.
To mirror the function h(m)
about the origin.
To slide h(-m) past f(m).
By adding a constant x
At each displacement,
the entire summation in
Eq(4.6-20) is carried out.
Periods of the f(m) and h(m) extending
Infinitely in both direction.
Part of the first extended
period to the right of
h(x-m) lies inside the part
of f(m)
Failure to handle the periodicity issue
78
properly will give incorrect result
Implementation (cont.)



Assume that f and h consist of A and B points
We append zeros to both functions so that they have
identical periods, denoted by P.
This procedure yields extended or padded functions
 f x  0  x  A  1
f e x   
A x P
 0
 g x  0  x  B  1
g e x   
BxP
 0

(4.6-21)
(4.6-22)
Unless we choose P>=A+B-1, the individual periods of the
convolution will overlap.


If P=A+B-1, the periods will be adjacent.
If P>A+B-1, the periods will be separated.
79
Implementation (cont.)
80
Implementation (cont.)

If we wanted to compute the convolution in the
frequency domain, we would



Obtain the Fourier transform of the two extended sequences.
Multiply the two transforms
Compute the inverse Fourier transform.
81
Implementation (cont.)

Extensions to 2D function



Images f(x,y) and h(x,y) of sizes AxB and CxD
Wraparound error in 2-D convolution is avoided by
choosing
P  A  C 1
Q  B  D 1
The periodic sequences are formed by extending f(x,y)
and h(x,y)
 f x, y  0  x  A  1 and 0  y  B  1
f e x, y   
A  x  P and B  y  Q
 0
hx, y  0  x  C  1 and 0  y  D  1
he x, y   
C  x  P and D  y  Q
 0
82
Implementation (cont.)
83
Implementation (cont.)
84
Implementation (cont.)

The Convolution and Correlation Theorems

兩函數f(x,y), h(x,y)的離散convolution可表示成
1 M 1 N 1
f ( x, y) * h( x, y) 
f (m, n)h( x  m, y  n)

MN m0 n0


(4.6-27)
Convolution和Fourier transform間的關係
f ( x, y) * h( x, y)  F (u, v) H (u, v)
(4.6-28)
f ( x, y)h( x, y)  F (u, v) * H (u, v)
(4.6-29)
兩函數f(x,y), h(x,y)的離散correlation可表示成
1 M 1 N 1 *
f ( x, y)  h( x, y) 
f (m, n)h( x  m, y  n)

MN m0 n0
(4.6-30)
85
Implementation (cont.)

空間與頻率上的correlation
f * ( x, y)h( x, y)  F (u, v)  H (u, v)
f ( x, y)  h( x, y)  F * (u, v) H (u, v)

Correlation可用在matching,假設f(x,y)是包含某些
物件的影像,h(x,y)為template,如果有匹配的話,
兩函數的correlation會有最大的值。
86
Implementation (cont.)
87
Chapter 4
Image Enhancement in the
Frequency Domain
88
Chapter 4
Image Enhancement in the
Frequency Domain
89
Chapter 4
Image Enhancement in the
Frequency Domain
90
Chapter 4
Image Enhancement in the
Frequency Domain
91
Chapter 4
Image Enhancement in the
Frequency Domain
92
Download