92
Chapter 4 Image Enhancement in the Frequency Domain 國國國國國國國國 國國國國國 國國國 (Chuan-Yu Chang ) 國國 Office: ES 709 TEL: 05-5342601 ext. 4337 E-mail: [email protected]

Chapter 4 Image Enhancement in the Frequency Domain

  • Upload
    violet

  • View
    57

  • Download
    2

Embed Size (px)

DESCRIPTION

Chapter 4 Image Enhancement in the Frequency Domain. 國立雲林科技大學 電子工程系 張傳育 (Chuan-Yu Chang ) 博士 Office: ES 709 TEL: 05-5342601 ext. 4337 E-mail: [email protected]. Background. Fourier series: - PowerPoint PPT Presentation

Citation preview

Page 1: Chapter 4 Image Enhancement in the Frequency Domain

Chapter 4Image Enhancement in the Frequency Domain

國立雲林科技大學 電子工程系張傳育 (Chuan-Yu Chang ) 博士Office: ES 709TEL: 05-5342601 ext. 4337E-mail: [email protected]

Page 2: Chapter 4 Image Enhancement in the Frequency Domain

2

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.

Page 3: Chapter 4 Image Enhancement in the Frequency Domain

3

The 1D Fourier Transform

The Fourier transform, F(u), of a single variable, continuous function, f(x), is defined as

We can obtain f(x) by means of the inverse Fourier transform

Extended to two variables, u and v.

dxexfuF uxj 2)()(

dvduevuFyxf

dydxeyxfvuF

vyuxj

vyuxj

)(2

)(2

),(),(

),(),(

(4.2-1)

(4.2-3)(4.2-4)

dueuFxf uxj 2)()( (4.2-2)

Fourier Transform Pair(4.2-1) and (4.2-2)

A function can be recovered from its transform.

Page 4: Chapter 4 Image Enhancement in the Frequency Domain

4

The 1D Fourier Transform (cont.) Discrete Fourier Transform, DFT

The concept of the frequency domain follows directly from Euler’s Formula

Substituting (4.2-7) into (4.2-5) obtain

1,...,2,1,0,)()(

1,...,2,1,0,)(1

)(

1

0

/2

1

0

/2

MxeuFxf

MuexfM

uF

M

x

muxj

M

x

muxj

sincos je j

1

0

/2sin/2cos)(1

)(M

x

MuxjMuxxfM

uF

(4.2-5)

(4.2-7)

(4.2-6)

(4.2-8)

在離散 FT 時,乘數所放的位置並不重要,可放在轉換前或轉換後,或者兩個都放,但須滿足其乘積為 1/M

每一分項稱為頻率成分(frequency component)

DFT:

IDFT:

Each term of the Fourier Transform is composed of the sum of all values of

the function f(x).

Page 5: Chapter 4 Image Enhancement in the Frequency Domain

5

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.

Page 6: Chapter 4 Image Enhancement in the Frequency Domain

6

The 1D Fourier Transform (cont.) As in the analysis of complex numbers, we

find it convenient sometimes to express F(u) in polar coordinates

)()()()(

)(

)(tan)(

)()()(

)()(

222

1

22

)(

uIuRuFuP

uR

uIu

uIuRuF

where

euFuF uj

(magnitude, spectrum)

(phase angle, phase spectrum)

(power spectrum, spectral density)

Rear part of F(u) imaginary part of F(u)

Page 7: Chapter 4 Image Enhancement in the Frequency Domain

7

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 x-domain 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

Page 8: Chapter 4 Image Enhancement in the Frequency Domain

8

The 1D Fourier Transform (cont.)

處理離散變數時,可以下式表示函數 f(x)

同理,因為頻率總是由零頻率開始,因此 F(u)

Fig. 4.2 顯示, f(x) 和 F(u) 成倒數關係

)()( 0 xxxfxf

)()( uuFuF

xMu

1

(4.2-13)

(4.2-14)

(4.2-15)

Page 9: Chapter 4 Image Enhancement in the Frequency Domain

9

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+kx).

The sequence always starts at true zero frequency. Thus the sequence for the values of u is 0, u, 2u,…,[M-1]u. The F(u)

x and u are inversely related by the expression (in Fig. 4.2)

)()( 0 xxxfxf

)()( uuFuF

xMu

1

(4.2-13)

(4.2-14)

(4.2-15)

Page 10: Chapter 4 Image Enhancement in the Frequency Domain

10

The 2D DFT and Its Inverse

2D DFT pair

1

0

1

0

)//(2

1

0

1

0

)//(2

),(),(

),(1

),(

M

u

N

v

NvyMuxj

M

x

N

y

NvyMuxj

evuFyxf

eyxfMN

vuF

),(),(),(),(

),(

),(tan),(

),(),(),(

222

1

22

vuIvuRvuFvuP

vuR

vuIvu

yxIyxRvuF

2D Fourier spectrum, phase angle, power spectrum

(4.2-16)

(4.2-17)

(4.2-18)

(4.2-19)

(4.2-20)

Page 11: Chapter 4 Image Enhancement in the Frequency Domain

11

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.

)2/,2/()1)(,( NvMuFyxf yx

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

(4.2-21)

Page 12: Chapter 4 Image Enhancement in the Frequency Domain

12

The 2D DFT and Its Inverse (cont.)

The value of the transform at (u,v)= (0,0) is

F(0,0) sometimes is called the dc component of the spectrum.

If f(x,y) is real, its Fourier transform is conjugate symmetric

1

0

1

0

),(1

)0,0(M

x

N

y

yxfMN

F

),(),(

),(),( *

vuFvuF

vuFvuF

yNv

xMu

1

1

(4.2-22)

(4.2-23)

(4.2-24)

(4.2-25)

(4.2-26)

The spectrum of the Fourier transform is symmetric.

Page 13: Chapter 4 Image Enhancement in the Frequency Domain

13

Example 4.2:Centered spectrum of a simple 2-D function

White rectangle of size 20x40 pixels The image was multiplied by (-1)x+y

prior to computing the Fourier transform

The image was processed

prior to displaying by using the log transformation in Eq.(3.2-

2)

Page 14: Chapter 4 Image Enhancement in the Frequency Domain

14

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.

Page 15: Chapter 4 Image Enhancement in the Frequency Domain

15

Example 4.3An image and its Fourier spectrum

Page 16: Chapter 4 Image Enhancement in the Frequency Domain

16

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

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)]

Filtering in the Frequency domain (cont.)

The multiplication of H and F involves two-dimensional functions and is defined on an element-by-element basis.

Page 17: Chapter 4 Image Enhancement in the Frequency Domain

17

Filtering in the Frequency domain (cont.)

Basics of filtering in the frequency domain1. Multiply the input image by (-1)x+y to center the transform

2. Compute F(u,v), the DFT of the image from (1)

3. Multiply F(u,v) by a filter function H(u,v)

4. Compute the inverse DFT of the result in (3)

5. Obtain the real part of the result in (4)

6. Multiply the result in (5) by (-1)x+y

Page 18: Chapter 4 Image Enhancement in the Frequency Domain

18

Filtering in the Frequency domain (cont.)

Basic steps for filtering in the frequency domain

Page 19: Chapter 4 Image Enhancement in the Frequency Domain

19

Some basis filters and their properties Notch filter

It is a constant function with a hole at the origin.

Set F(0,0) to zero and leave all other frequency components of the Fourier transform untouched.

otherwise

NMvuifvuH

1

2/,2/,0,

Page 20: Chapter 4 Image Enhancement in the Frequency Domain

20

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.

Page 21: Chapter 4 Image Enhancement in the Frequency Domain

21

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.

Page 22: Chapter 4 Image Enhancement in the Frequency Domain

22

Lowpass

Highpass

The effects of lowpass and highpass filtering

Blurred image

Sharp image withlittle smooth graylevel detail becausethe F(0,0) has beenset to zero.

Page 23: Chapter 4 Image Enhancement in the Frequency Domain

23

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

Page 24: Chapter 4 Image Enhancement in the Frequency Domain

24

Correspondence between Filtering in the Spatial and Frequency Domains Convolution theorem

1

0

1

0

),(),(1

),(*),(M

m

N

n

nymxhnmfMN

yxhyxf

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).

(4.2-30)

Page 25: Chapter 4 Image Enhancement in the Frequency Domain

25

Correspondence between Filtering in the Spatial and Frequency Domains (cont.) Fourier transform pair

Impulse function of strength A

00

1

0

1

000 ,,),( yxAsyyxxAyxs

M

x

N

y

),(*),(),(),(

),(),(),(),(

vuHvuFyxhyxf

vuHvuFyxhyxf

0,0,),(1

0

1

0

syxyxsM

x

N

y

( 位於原點的單位脈衝 )

(4.2-31)

(4.2-32)

(4.2-33)

(4.2-34)

Used to indicate that the expression on the left can be obtained by taking

the IFT of the expression on the right.

Page 26: Chapter 4 Image Enhancement in the Frequency Domain

26

Correspondence between Filtering in the Spatial and Frequency Domains (cont.) The Fourier transform of a unit impulse at the origin

Let f(x,y)=(x,y), Eq.(4.2-30) and (4.2-34)

MN

eyxMN

vuFM

x

N

y

NvyMuxj

1

),(1

),(1

0

1

0

)//(2

),(1

),(),(1

),(*),(1

0

1

0

yxhMN

nymxhnmMN

yxhyxfM

m

N

n

(4.2-35)

(4.2-36)

Page 27: Chapter 4 Image Enhancement in the Frequency Domain

27

Correspondence between Filtering in the Spatial and Frequency Domains (cont.) Based on (4.2-31), combining (4.2-35) and (4.2-36)

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.

),(),(

),(),(),(),(

),(),(),(),(

vuHyxh

vuHyxyxhyx

vuHvuFyxhyxf

(4.2-37)

Page 28: Chapter 4 Image Enhancement in the Frequency Domain

28

Introduction to the Fourier Transform and the Frequency Domain (cont.) 高斯濾波器 (Gaussian Filter)

The corresponding filter in the spatial domain

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) 有較窄的剖面。

22 2/)( uAeuH

22222)( xAexh

Page 29: Chapter 4 Image Enhancement in the Frequency Domain

29

Introduction to the Fourier Transform and the Frequency Domain (cont.) We can construct a highpass filter as a difference of

Gaussians, as follows:

With A>=B and 1>2. The corresponding filter in the spatial domain is

22

221

2 2/2/)( uu BeAeuH

222

2221

2 22

21 22)( xx AeAexh

Page 30: Chapter 4 Image Enhancement in the Frequency Domain

30

Introduction to the Fourier Transform and the Frequency Domain (cont.)

We can implement lowpass filtering in the spatial domain by using a mask with all positive coefficients.

Once the values turn negative, they never turn positive again.

Page 31: Chapter 4 Image Enhancement in the Frequency Domain

31

22

0

0

)2/()2/(),(

),(0

),(1),(

NvMuvuD

DvuDif

DvuDifvuH

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.

(4.3-2)

(4.3-3)

從點 (u,v) 到傅立葉轉換中心點的距離

Page 32: Chapter 4 Image Enhancement in the Frequency Domain

32

1

0

1

0

),(M

u

N

vT vuPP

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).

百分比功率 (% of the power)

u vTPvuP /),(100

(4.3-4)

(4.3-5)

Page 33: Chapter 4 Image Enhancement in the Frequency Domain

33

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

Page 34: Chapter 4 Image Enhancement in the Frequency Domain

34

Example 4.4 Image power as a function of distance from the origin of the DFT (cont.)存在振鈴現象

(ringing)

Page 35: Chapter 4 Image Enhancement in the Frequency Domain

35

Smoothing Frequency-Domain Filters (cont.)

Page 36: Chapter 4 Image Enhancement in the Frequency Domain

36

Smoothing Frequency-Domain Filters (cont.) 巴特沃斯特低通濾波器 (Butterworth Lowpass Filter)

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) 降到最大值的某個比例時。 )

nDvuDvuH 2

0/),(1

1),(

Page 37: Chapter 4 Image Enhancement in the Frequency Domain

37

Smoothing Frequency-Domain Filters (cont.)

一階的 BLPF 沒有振鈴也沒有負值。

二階的 BLPF 有輕微的振鈴,有小負值。

高階的 BLPF 有明顯的振鈴,

Page 38: Chapter 4 Image Enhancement in the Frequency Domain

38

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.

Page 39: Chapter 4 Image Enhancement in the Frequency Domain

39

Smoothing Frequency-Domain Filters (cont.) 高斯低通濾波器 (Gaussian Lowpass Filters)

Let =D0,

where D0 is the cutoff frequency.

22 2/,),( vuDevuH

20

2 2/,),( DvuDevuH

Page 40: Chapter 4 Image Enhancement in the Frequency Domain

40

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.

Page 41: Chapter 4 Image Enhancement in the Frequency Domain

41

Smoothing Frequency-Domain Filters (cont.) A sample of text of poor resolution

Using a Gaussian lowpass filter with

Page 42: Chapter 4 Image Enhancement in the Frequency Domain

42

Smoothing Frequency-Domain Filters (cont.) A sample of text of poor resolution

Using a Gaussian lowpass filter with D0=80 to repair the text.

Page 43: Chapter 4 Image Enhancement in the Frequency Domain

43

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.

Page 44: Chapter 4 Image Enhancement in the Frequency Domain

44

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.

Page 45: Chapter 4 Image Enhancement in the Frequency Domain

45

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

vuHvuH lphp ,1,

Page 46: Chapter 4 Image Enhancement in the Frequency Domain

46

Sharpening Frequency Domain Filters 理想高通濾波器 (Ideal Highpass Filters)

巴特沃斯高通濾波器 (Butterworth Highpass Filters)

高斯高通濾波器 (Gaussian Highpass Filters)

0

0

),(1

),(0),(

DvuDif

DvuDifvuH

nvuDDvuH 2

0 ),(/1

1),(

20

2 2/,1),( DvuDevuH

(4.4-2)

(4.4-3)

(4.4-4)

Page 47: Chapter 4 Image Enhancement in the Frequency Domain

47

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.

Page 48: Chapter 4 Image Enhancement in the Frequency Domain

48

Sharpening Frequency Domain Filters (cont.) Spatial representations of typical (a) ideal (b)

Butterworth, and (c) Gaussian frequency domain highpass filters

Page 49: Chapter 4 Image Enhancement in the Frequency Domain

49

Sharpening Frequency Domain Filters (cont.) Result of ideal highpass filtering (a) with D0=15,

30, and 80 IHPFs have ringing properties.

Page 50: Chapter 4 Image Enhancement in the Frequency Domain

50

Sharpening Frequency Domain Filters (cont.)

Result of BHPF order 2 highpass filtering (a) with D0=15, 30, and 80

Page 51: Chapter 4 Image Enhancement in the Frequency Domain

51

Sharpening Frequency Domain Filters (cont.)

Result of GHPF order 2 highpass filtering (a) with D0=15, 30, and 80

Page 52: Chapter 4 Image Enhancement in the Frequency Domain

52

Sharpening Frequency Domain Filters (cont.) The Laplacian in the Frequency Domain

It can be shown that

Extended to two dimension

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

uFjudx

xfd n

n

n

vuFvu

vuFjvvuFjuy

yxf

x

yxf

,

,,,,

22

22

2

2

2

2

vuFvuyxf ,, 222

(4.4-5)

(4.4-6)

(4.4-7)

Laplacian

Page 53: Chapter 4 Image Enhancement in the Frequency Domain

53

Sharpening Frequency Domain Filters (cont.) Eq(4.4-7) presents that the Laplacian can be implemented in the

frequency domain by using the filter

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:

The Laplacian filtered image in the spatial domain is obtained by computing the inverse Fourier transform of H(u,v)F(u,v)

22),( vuvuH

22 )2/()2/(),( NvMuvuH

),(2/2/, 2212 vuFNvMuyxf

(4.4-8)

(4.4-9)

(4.4-10)

Page 54: Chapter 4 Image Enhancement in the Frequency Domain

54

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).

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.

vuFNvMuyxf ,2/2/, 222 (4.4-11)

Page 55: Chapter 4 Image Enhancement in the Frequency Domain

55

Sharpening Frequency Domain Filters (cont.)

Page 56: Chapter 4 Image Enhancement in the Frequency Domain

56

Sharpening Frequency Domain Filters (cont.)

We form an enhanced image g(x,y) by subtracting the Laplacian from the original image

在頻率域,也有類似的效果

),(),(),( 2 yxfyxfyxg

),(2/2/1),( 221 vuFNvMuyxg

(4.4-12)

(4.4-13)

Page 57: Chapter 4 Image Enhancement in the Frequency Domain

57

Sharpening Frequency Domain Filters (cont.)

在空間域,可將原始影像減去 Laplacian 來形成一幅增強後的影像

在頻率域,也有類似的效果

),(),(),( 2 yxfyxfyxg

),(2/2/1),( 221 vuFNvMuyxg

(4.4-12)

(4.4-13)

Page 58: Chapter 4 Image Enhancement in the Frequency Domain

58

Sharpening Frequency Domain Filters (cont.)

Page 59: Chapter 4 Image Enhancement in the Frequency Domain

59

Unsharp masking, high-boost filtering 鈍化遮罩 (unsharp masking)

藉由減去影像自己的模糊化版本,所得到的銳化影像 藉由減去影像自己的低通濾波版本,以獲得高通濾波影像

High-boot filtering multiplying f(x,y) by a constant A>=1.

(4.4-15) 可改寫成

將 (4.4-14) 代入,可得

),(),(),( yxfyxfyxf lphp

),(),(),( yxfyxAfyxf lphb

),(),(),()1(),( yxfyxfyxfAyxf lphb

),(),()1(),( yxfyxfAyxf hphb

(4.4-14)

(4.4-15)

(4.4-16)

(4.4-17)

Page 60: Chapter 4 Image Enhancement in the Frequency Domain

60

Unsharp masking, high-boost filtering (cont.)

從上式的推導,鈍化遮罩可使用下列的複合濾波器直接在頻率域上實現

所以, high-boot filtering 可以下列複合濾波器在頻率域上實現

),(1),(

),(),(),(),(

),(),(),(

),(),(),(

vuHvuF

vuFvuHvuFvuF

vuFvuHvuF

vuFvuFvuF

lp

lphp

lplp

lphp

),(1),( vuHvuH lphp (4.4-18)

),()1(),( vuHAvuH hphb (4.4-19)

Page 61: Chapter 4 Image Enhancement in the Frequency Domain

61

Sharpening Frequency Domain Filters (cont.)

Page 62: Chapter 4 Image Enhancement in the Frequency Domain

62

Sharpening Frequency Domain Filters (cont.)

Page 63: Chapter 4 Image Enhancement in the Frequency Domain

63

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:

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

However, we define

Then

or

),(),(),( yxryxiyxf

yxryxiyxf ,,),(

yxryxi

yxfyxz

,ln,ln

,ln,

yxryxi

yxfyxz

,ln,ln

,ln),(

(4.5-1)

(4.5-2)

(4.5-3)

vuFvuFvuZ ri ,,, (4.5-4)

Page 64: Chapter 4 Image Enhancement in the Frequency Domain

64

Homomorphic filter If we process Z(u,v) by means of a filter function H(u,v) then

from Eq.(4.2-27)

In spatial domain,

By letting

and

Eq. (4.5-6) can be expressed in the form

vuFvuHvuFvuH

vuZvuHvuS

ri ,,,,

,,,

vuFvuHvuFvuH

vuSyxs

ri ,,,,

,,11

1

vuFvuHyxi i ,,, 1'

vuFvuHyxr r ,,, 1'

yxryxiyxs ,,, ''

(4.5-5)

(4.5-6)

(4.5-7)

(4.5-8)

(4.5-9)

Page 65: Chapter 4 Image Enhancement in the Frequency Domain

65

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)

Where

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.

),(),(

,

00

),('),('

,

yxryxi

ee

eyxgyxryxi

yxs

),('0

),('0

),(

),(yxr

yxi

eyxr

eyxi

(4.5-10)

(4.5-11)

(4.5-12)

Page 66: Chapter 4 Image Enhancement in the Frequency Domain

66

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.

Page 67: Chapter 4 Image Enhancement in the Frequency Domain

67

L

DvuDcLH evuH

2

02 /,1,

rH>1

rL<1

抑制低頻 ( 照明 ) ,並放大高頻 ( 反射 ) ,增加影像的對比度

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.

Page 68: Chapter 4 Image Enhancement in the Frequency Domain

68

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.

Page 69: Chapter 4 Image Enhancement in the Frequency Domain

69

Implementation Some additional properties of the 2D Fourier

Transform Translation properties:

when u0=M/2, v0=N/2

Eq(4.6-1) becomes

00//2 ,, 00 vvuuFeyxf NyvMxuj

NvyMuxjevuFyyxxf //200

00,,

yxyxjNyvMxuj ee 1//2 00

2/,2/1, NvMuFyxf yx

vuvuFNyMxf 1,2/,2/

(4.6-1)

(4.6-2)

(4.6-3)

(4.6-4)

Same as Eq(4.2-21), which we used for centering the transform.

Page 70: Chapter 4 Image Enhancement in the Frequency Domain

70

Implementation (cont.)

Distributivity The Fourier transform is distributive over addition, but not

over multiplication

Scaling

yxfyxfyxfyxf ,,,, 2121

yxfyxfyxfyxf ,,,, 2121

bvauFab

byaxf

vuaFyxaf

/,/1

,

,,

(4.6-5)

(4.6-6)

(4.6-7)

(4.6-8)

Page 71: Chapter 4 Image Enhancement in the Frequency Domain

71

Implementation (cont.)

Rotation If we introduce the polar coordinates x=r cos , y=r sin , u=w cos , v= w sin then f(x,y) and F(u,v) become f(, ) and F(, ) Direct substitution into the definition of the Fourier transform

yields

The expression indicates that rotating f(x,y) by an angle 0 rotates F(u,v) by the same angle.

00 ,, Frf (4.6-9)

Page 72: Chapter 4 Image Enhancement in the Frequency Domain

72

Implementation (cont.)

Periodicity symmetry

Conjugate symmetry

NvMuFNvuFvMuFvuF ,,,,

NyMxfNyxfyMxfyxf ,,,,

vuFvuF

vuFvuF

,,

,, *

Page 73: Chapter 4 Image Enhancement in the Frequency Domain

73

週期性表示 F(u) 有一長度為 M 的週期共軛對稱性表示頻譜的中心位於原點

Implementation (cont.)

Page 74: Chapter 4 Image Enhancement in the Frequency Domain

74

Implementation (cont.) Separability

The discrete Fourier transform in Eq(4.2-16) can be expressed in the separable form

where

1

0

/2

1

0

/21

0

/2

,1

,11

,

M

x

Muxj

N

y

nvyjM

x

Muxj

evxFM

eyxfN

eM

vuF

1

0

/2,1

,N

y

nvyjeyxfN

vxF

(4.6-14)

(4.6-15)

Page 75: Chapter 4 Image Enhancement in the Frequency Domain

75

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

Taking the complex conjugate of Eq(4.6-17) and dividing both sides by M yields

1,...,2,1,0,)(1

)(1

0

/2

MuexfM

uFM

x

Muxj

1,...,2,1,0,)()(1

0

/2

MxeuFxf

M

x

Muxj

1,...,2,1,0,)(*1

)(*1 1

0

/2

MxeuF

Mxf

M

M

x

Muxj

(4.6-16)

(4.6-17)

(4.6-18)

Both (4.6-16) and (4.6-18) have same form

Page 76: Chapter 4 Image Enhancement in the Frequency Domain

76

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

0

)//(21

0

),(*1

),(*1 M

x

NvyMuxjN

y

evuFMN

yxfMN

(4.6-19)

Page 77: Chapter 4 Image Enhancement in the Frequency Domain

77

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

0

)()(1

)(*)(M

m

mxhmfM

xhxf (4.6-20)

Page 78: Chapter 4 Image Enhancement in the Frequency Domain

78

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) extendingInfinitely in both direction.

Part of the first extendedperiod to the right ofh(x-m) lies inside the partof f(m)

Failure to handle the periodicity issueproperly will give incorrect result

Page 79: Chapter 4 Image Enhancement in the Frequency Domain

79

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

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.

PxB

Bxxgxg

PxA

Axxfxf

e

e

0

10

0

10(4.6-21)

(4.6-22)

Page 80: Chapter 4 Image Enhancement in the Frequency Domain

80

Implementation (cont.)

Page 81: Chapter 4 Image Enhancement in the Frequency Domain

81

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.

Page 82: Chapter 4 Image Enhancement in the Frequency Domain

82

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

The periodic sequences are formed by extending f(x,y) and h(x,y)

1

1

DBQ

CAP

QyDPxC

DyCxyxhyxh

QyBPxA

ByAxyxfyxf

e

e

and 0

10 and 10,,

and 0

10 and 10,,

Page 83: Chapter 4 Image Enhancement in the Frequency Domain

83

Implementation (cont.)

Page 84: Chapter 4 Image Enhancement in the Frequency Domain

84

Implementation (cont.)

Page 85: Chapter 4 Image Enhancement in the Frequency Domain

85

Implementation (cont.)

The Convolution and Correlation Theorems 兩函數 f(x,y), h(x,y) 的離散 convolution 可表示成

Convolution 和 Fourier transform 間的關係

兩函數 f(x,y), h(x,y) 的離散 correlation 可表示成

1

0

1

0

),(),(1

),(*),(M

m

N

n

nymxhnmfMN

yxhyxf

),(),(),(*),( vuHvuFyxhyxf

),(*),(),(),( vuHvuFyxhyxf

1

0

1

0

* ),(),(1

),(),(M

m

N

n

nymxhnmfMN

yxhyxf

(4.6-27)

(4.6-28)

(4.6-29)

(4.6-30)

Page 86: Chapter 4 Image Enhancement in the Frequency Domain

86

Implementation (cont.)

空間與頻率上的 correlation

Correlation 可用在 matching ,假設 f(x,y) 是包含某些物件的影像, h(x,y) 為 template ,如果有匹配的話,兩函數的 correlation 會有最大的值。

),(),(*),(),( vuHvuFyxhyxf ),(),(),(),(* vuHvuFyxhyxf

Page 87: Chapter 4 Image Enhancement in the Frequency Domain

87

Implementation (cont.)

Page 88: Chapter 4 Image Enhancement in the Frequency Domain

88

Chapter 4Image Enhancement in the

Frequency Domain

Chapter 4Image Enhancement in the

Frequency Domain

Page 89: Chapter 4 Image Enhancement in the Frequency Domain

89

Chapter 4Image Enhancement in the

Frequency Domain

Chapter 4Image Enhancement in the

Frequency Domain

Page 90: Chapter 4 Image Enhancement in the Frequency Domain

90

Chapter 4Image Enhancement in the

Frequency Domain

Chapter 4Image Enhancement in the

Frequency Domain

Page 91: Chapter 4 Image Enhancement in the Frequency Domain

91

Chapter 4Image Enhancement in the

Frequency Domain

Chapter 4Image Enhancement in the

Frequency Domain

Page 92: Chapter 4 Image Enhancement in the Frequency Domain

92

Chapter 4Image Enhancement in the

Frequency Domain

Chapter 4Image Enhancement in the

Frequency Domain