chapter 4 image enhancement in the frequency...

98
Chapter 4 Image Enhancement in the Frequency Domain 國立雲林科技大學 資訊工程系 張傳育(Chuan-Yu Chang ) 博士 Office: EB 212 TEL: 05-5342601 ext. 4516 E-mail: [email protected] Web: http://MIPL.yuntech.edu.tw

Upload: others

Post on 25-Feb-2021

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

Chapter 4

Image Enhancement in the

Frequency Domain

國立雲林科技大學資訊工程系

張傳育(Chuan-Yu Chang ) 博士

Office: EB 212

TEL: 05-5342601 ext. 4516

E-mail: [email protected]

Web: http://MIPL.yuntech.edu.tw

Page 2: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

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.

n

xT

nj

necxf

2

Page 3: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

3

Background

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 4: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

4

Function s(x) (in red) is a sum of six sine functions of different amplitudes

and harmonically related frequencies.

Their summation is called a Fourier series.

The Fourier transform, S(f) (in blue), which depicts amplitude vs frequency,

reveals the 6 frequencies (at odd harmonics) and their amplitudes (1/odd

number).

Ref. Wikipedia (https://en.wikipedia.org/wiki/Fourier_series)

Page 5: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

5

The 1D Fourier Transform

The Fourier transform, F(u), of a single variable, continuous

function, f(x), is defined as

where

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

Extended to two variables, u and v.

dueuFxf uxj 2)()(

dxexfuF uxj 2)()(

dvduevuFyxf

dydxeyxfvuF

vyuxj

vyuxj

)(2

)(2

),(),(

),(),(

(4.2-1)

(4.2-3)

(4.2-4)

(4.2-2)

Fourier Transform Pair

(4.2-1) and (4.2-2)

A function can be recovered

from its transform.

1j

Page 6: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

6

The 1D Fourier Transform (cont.)

Discrete Fourier Transform, DFT, of one variable

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

Formula

Substituting (4.2-7) into (4.2-5), and using cos(-q )=cos( q ) 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

qqq sincos je j

1

0

/2sin/2cos)(1

)(

M

x

MuxjMuxxfM

uF

(4.2-5)

(4.2-7)

(4.2-6)

(4.2-8)

在DFT時,乘數所放的位置並不重要,可放在轉換前或轉換後,或者兩個都放1/√M,但須滿足其乘積為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).

1,...,2,1,0, Mxxf

Page 7: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

7

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

)()()(

where

)()(

222

1

22

)(

uIuRuFuP

uR

uIu

uIuRuF

euFuF uj

(magnitude, spectrum)

(phase angle, phase spectrum)

(power spectrum, spectral density)

Rear part of F(u)

imaginary part of F(u)

Page 8: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

8

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

u=0

Page 9: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

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 Dx units away to give f(x0+Dx). The k-th sample, f(k), is f(x0+kDx).

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

Dx and Du are inversely related by the expression (in Fig. 4.2)

)()( 0 xxxfxf D

)()( uuFuF D

xMu

DD

1

(4.2-13)

(4.2-14)

(4.2-15)

Page 10: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

10

Discrete-time Fourier transform

The discrete-time Fourier transform (DTFT) is

a form of Fourier analysis that is applicable to

the uniformly-spaced samples of a

continuous function.

The term discrete-time refers to the fact that

the transform operates on discrete data

(samples) whose interval often has units of

time.

Page 11: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

11Depiction of a Fourier transform and its periodic summation (DTFT)

Ref. Wikipedia (https://en.wikipedia.org/wiki/Discrete-time_Fourier_transform)

Page 12: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

12

The 2D DFT and Its Inverse

2D DFT pair The discrete Fourier transform of a function f(x,y) of size MxN is

given by

where u=0,1,2,…,M-1, v=0,1,2,…,N-1

The inverse Fourier transform is given by

1

0

1

0

)//(2),(1

),(M

x

N

y

NvyMuxjeyxfMN

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)

1

0

1

0

)//(2),(),(M

u

N

v

NvyMuxjevuFyxf

Page 13: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

13

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)

M,N須為偶數

Page 14: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

14

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

Dx and Du are inversely related by

1

0

1

0

),(1

)0,0(M

x

N

y

yxfMN

F

),(),(

),(),( *

vuFvuF

vuFvuF

yNv

xMu

DD

DD

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 15: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

15

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 16: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

16

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 17: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

17

Page 18: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

18

The spectrum corresponding to the translated rectangle is identical to the

spectrum corresponding to the original image.

Page 19: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

19

Page 20: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

20

Example 4.3

An image and its Fourier spectrum

放大2500倍

Page 21: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

21

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 22: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

22

Filtering in the Frequency domain (cont.)

Basics steps for filtering in the frequency domain

1. 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 23: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

23

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 24: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

24

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 25: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

25

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 26: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

26

Lowpass

Highpass

The effects of lowpass and highpass filtering

blurred image

Sharp image with

little smooth gray

level detail because

the F(0,0) has been

set to zero.

original image

Page 27: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

27

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 28: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

28

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 29: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

29

Correspondence between Filtering in the Spatial

and Frequency Domains (cont.)

Fourier transform pair

Impulse function of strength A, located at coordinates (x0, y0), is

denoted by Ad(x-x0, y-y0) and is defined by

A unit impulse located at the origin, which is denoted as d(x,y)

00

1

0

1

0

00 ,,),( yxAsyyxxAyxsM

x

N

y

d

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

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

vuHvuFyxhyxf

vuHvuFyxhyxf

0,0,),(1

0

1

0

syxyxsM

x

N

y

d (位於原點的單位脈衝)

(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 30: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

30

Page 31: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

31

Correspondence between Filtering in the Spatial

and Frequency Domains (cont.)

The Fourier transform of a unit impulse at the origin

Let f(x,y)=d(x,y), carry out the convolution defined in

Eq.(4.2-30), using (4.2-34)

MN

eyxMN

vuFM

x

N

y

NvyMuxj

1

),(1

),(1

0

1

0

)//(2

d

),(1

),(),(1

),(*),(1

0

1

0

yxhMN

nymxhnmMN

yxhyxfM

m

N

n

d

(4.2-35)

(4.2-36)

只有在(x,y) = (0,0)時為1,其餘為0

在原點上的impulse Fouier Transform為實數值,相位角為0。如果impulse不在原點,則轉換後會產生非零的相位角(magnitude相同,但會平移)。

只有在(m,n) = (0,0)時為1,其餘為0

Page 32: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

32

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

dd (4.2-37)

Page 33: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

33

Introduction to the Fourier Transform

and the Frequency Domain (cont.) 高斯濾波器(Gaussian Filter)

The corresponding filter in the spatial domain is

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

is the standard deviation

of the Gaussian curve

Page 34: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

34

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 2

2

2

1 22)(xx

BeAexh

Page 35: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

35

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 36: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

36

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 37: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

37

1

0

1

0

),(M

u

N

v

T 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 v

TPvuP /),(100

(4.3-4)

(4.3-5)

Page 38: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

38

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 39: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

39

Example 4.4 Image power as a function of

distance from the origin of the DFT (cont.)

存在振鈴現象(ringing)

Page 40: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

40

Smoothing Frequency-Domain Filters (cont.)

對角線的profile

對角線的profile

Page 41: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

41

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

nDvuD

vuH2

0/),(1

1),(

Page 42: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

42

Smoothing Frequency-Domain Filters (cont.)

2階巴特沃斯特低通濾波器,截止頻率半徑分別為5, 15, 30, 80,及230的結果。

Page 43: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

43

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.

order 1 order 2 order 5 order 20

Page 44: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

44

Smoothing Frequency-Domain Filters (cont.)

高斯低通濾波器(Gaussian Lowpass Filters)

Let = D0,

where D0 is the cutoff frequency.

22 2/,),( vuDevuH

20

2 2/,),(

DvuDevuH

Page 45: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

45

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 46: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

46

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 47: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

47

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 48: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

48

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 49: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

49

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, (4.4-1)

Page 50: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

50

Sharpening Frequency Domain Filters

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

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

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

0

0

),(1

),(0),(

DvuDif

DvuDifvuH

nvuDD

vuH2

0 ),(/1

1),(

20

2 2/,1),(

DvuDevuH

(4.4-2)

(4.4-3)

(4.4-4)

Page 51: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

51

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 52: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

52

Sharpening Frequency Domain Filters (cont.)

Spatial representations of typical (a) ideal (b)

Butterworth, and (c) Gaussian frequency domain

highpass filters

Page 53: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

53

Sharpening Frequency Domain Filters (cont.)

Result of ideal highpass filtering (a) with D0=15,

30, and 80

IHPFs have ringing properties.

Page 54: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

54

Sharpening Frequency Domain Filters (cont.)

Result of BHPF order 2 highpass filtering (a) with

D0=15, 30, and 80

Page 55: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

55

Sharpening Frequency Domain Filters (cont.)

Result of GHPF order 2 highpass filtering (a) with

D0=15, 30, and 80

Page 56: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

56

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

uFju

dx

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 57: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

57

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 58: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

58

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

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 59: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

59

Sharpening Frequency Domain Filters (cont.)

Page 60: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

60

Sharpening Frequency Domain Filters (cont.)

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

Laplacian from the original image

In Frequency domain, the enhanced image is obtained by

perform the operation with only one filter,

the enhanced image is obtained with a signal inverse

transform operation:

),(),(),( 2 yxfyxfyxg

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

(4.4-12)

(4.4-13)

222/2/1, NvMuvuH

Page 61: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

61

Sharpening Frequency Domain Filters (cont.)

Page 62: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

62

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 63: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

63

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 64: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

64

Sharpening Frequency Domain Filters (cont.)

Page 65: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

65

Sharpening Frequency Domain Filters (cont.)

Page 66: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

66

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 67: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

67

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 68: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

68

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

eyxg

yxryxi

yxs

),('0

),('0

),(

),(

yxr

yxi

eyxr

eyxi

(4.5-10)

(4.5-11)

(4.5-12)

Page 69: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

69

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 70: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

70

L

DvuDcLH evuH

20

2 /,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 71: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

71

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 72: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

72

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 vvuuFeyxfNyvMxuj

NvyMuxjevuFyyxxf

//200

00,,

yxyxjNyvMxujee

1

//2 00

2/,2/1, NvMuFyxfyx

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 73: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

73

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 74: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

74

Implementation (cont.)

Rotation

If we introduce the polar coordinates

x=r cos q, y=r sin q, u=w cos j, v= w sin j

then f(x,y) and F(u,v) become f(, q) and F(w, j)

Direct substitution into the definition of the Fourier transform

yields

The expression indicates that rotating f(x,y) by an angle q0

rotates F(u,v) by the same angle.

00 ,, qjwqq Frf (4.6-9)

Page 75: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

75

Implementation (cont.)

Periodicity symmetry

Conjugate symmetry

NvMuFNvuFvMuFvuF ,,,,

NyMxfNyxfyMxfyxf ,,,,

vuFvuF

vuFvuF

,,

,, *

The complex conjugate of a complex number is the number with equal real part and imaginary part equal in

magnitude but opposite in sign. For example, the complex conjugate of 3 + 4i is 3 − 4i.

Page 76: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

76

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

Implementation (cont.)

Page 77: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

77

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)

1

0

1

0

)//(2),(1

),(M

x

N

y

NvyMuxjeyxfMN

vuF

Page 78: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

78

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

MxeuFxfM

x

Muxj

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

)(*1 1

0

/2

MxeuFM

xfM

M

x

Muxj

(4.6-16)

(4.6-17)

(4.6-18)

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

Page 79: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

79

The complex conjugate of a

complex number is the number

with equal real part and imaginary

part equal in magnitude but

opposite in sign.

Ex: the complex conjugate of 3 + 4j is

3 − 4j.

Implementation (cont.)

Page 80: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

80

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 81: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

81

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 82: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

82

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

properly will give incorrect result

Page 83: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

83

Implementation (cont.)

Assume that f and g 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 84: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

84

Implementation (cont.)

Page 85: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

85

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 86: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

86

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,,

Padding是必要的!因為在頻率域中,濾波的動作是將影像和濾波函數進行點乘的動作。

Page 87: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

87

Implementation (cont.)

Page 88: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

88

Implementation (cont.)

對圖4.12(c)以padded過的ideal low

pass filter,點乘後的結果。

對圖4.39 進行inverse Fourier

Transfer後的結果。

我們只須取出左上角的部分。

Page 89: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

89

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)

對於空間域的影像而言,由於沒有complex部分,所以f*=f,

Page 90: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

90

Implementation (cont.)

空間與頻率上的correlation

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

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

),(),(),(),(* vuHvuFyxhyxf (4.6-32)

(4.6-31)

Page 91: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

91

Implementation (cont.)

Correlation

Cross correlation

The image being correlated are different.

Autocorrelation

Both images are identical.

The autocorrelation theorem

the Fourier transform of the spatial autocorrelation is

the power spectrum.

Similarly, according to Eq.(4.6-32), we have

2),(),(),( vuFyxhyxf

),(),(),(2

vuFvuFyxf (4.6-34)

(4.6-33)

Page 92: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

92

Implementation (cont.)

256

256

42

38

256+42-1=297

256+38-1=293Padded images

最大的correlation

value出現在”T”上面。

Page 93: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

93

Chapter 4Image Enhancement in the

Frequency Domain

Page 94: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

94

Chapter 4Image Enhancement in the

Frequency Domain

Page 95: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

95

Chapter 4Image Enhancement in the

Frequency Domain

Page 96: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

96

Chapter 4Image Enhancement in the

Frequency Domain

Page 97: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

97

Chapter 4Image Enhancement in the

Frequency Domain

Page 98: Chapter 4 Image Enhancement in the Frequency Domainmipl.yuntech.edu.tw/wp-content/uploads/2020/03/Chapter04... · 2020. 3. 17. · 9 The 1D Fourier Transform (cont.) In the discrete

98