115
Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

  • View
    233

  • Download
    8

Embed Size (px)

Citation preview

Page 1: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Digital Image Processing

Chapter 4: Image Enhancement in the Frequency Domain

Page 2: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Background

The French mathematiian Jean Baptiste Joseph Fourier Born in 1768 Published Fourier series in 1822 Fourier’s ideas were met with

skepticism Fourier series

Any periodical function can be expressed as the sum of sines and/or cosines of different frequencies, each multiplied by a different coefficient

Page 3: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain
Page 4: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Fourier transform Functions can be expressed as the

integral of sines and/or cosines multiplied by a weighting function

Functions expressed in either a Fourier series or transform can be reconstructed completely via an inverse process with no loss of information

1),( yx2222222 2/)()(222 vuyx AeeA

Page 5: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Applications Heat diffusion Fast Fourier transform (FFT) developed

in the late 1950s

Page 6: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Introduction to the Fourier Transform and the Frequency Domain

The one-dimensional Fourier transform and its inverse Fourier transform

Inverse Fourier transform

dxexfuF uxj 2)()(

dueuFxf uxj 2)()(

Page 7: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Two variables

dxdyeyxfvuF vyuxj )( 2),(),(

dudvevuFyxf vyuxj )( 2),(),(

Fourier transform

Inverse Fourier transform

Page 8: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Discrete Fourier transform (DFT) Original variable

Transformed variable

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

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

Page 9: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

1,...,2,1,0

,)(1

)(1

0

/ 2

Mu

exfM

uFM

x

Muxj

1,...,2,1,0

,)()(1

0

/ 2

Mx

euFxfM

u

Muxj

Page 10: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

DFT The discrete Fourier transform and its

inverse always exist f(x) is finite in the book

Page 11: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Sines and cosines

sincos je j

1

0

]/ 2sin/ 2)[cos(1

)(M

x

MuxjMuxxfM

uF

Page 12: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Time domain

Time components

Frequency domain

Frequency components

x

)(xf

u

)(uF

Page 13: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Fourier transform and a glass prism Prism

Separates light into various color components, each depending on its wavelength (or frequency) content

Fourier transform Separates a function into various

components, also based on frequency content

Mathematical prism

Page 14: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Polar coordinates

Real part

Imaginary part

)()()( ujeuFuF

)(uR

)(uI

Page 15: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Magnitude or spectrum

Phase angle or phase spectrum

Power spectrum or spectral density

2122 )()()( uIuRuF

)(

)(tan)( 1

uR

uIu

)()()()( 222uIuRuFuP

Page 16: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain
Page 17: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Samples

)()( 0 xxxfxf

)()( uuFuF

xMu

1

Page 18: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Some references http://local.wasp.uwa.edu.au/~pbourke/

other/dft/ http://homepages.inf.ed.ac.uk/rbf/HIPR2

/fourier.htm

Page 19: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Examples test_fft.c fft.h fft.c Fig4.03(a).bmp test_fig2.bmp

Page 20: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

The two-dimensional DFT and its inverse

1,...,2,1,0

1,...,2,1,0

,),(1

),(1

0

1

0

)// (2

Nv

Mu

eyxfMN

vuFM

x

N

y

NvyMuxj

Page 21: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Spatial, or image variables: x, y Transform, or frequency variables:

u, v

1,...,2,1,0y

1,...,2,1,0 x

,),(),(1

0

1

0

)// (2

N

M

evuFyxfM

u

N

v

NvyMuxj

Page 22: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Magnitude or spectrum

Phase angle or phase spectrum

Power spectrum or spectral density

2122 ),(),(),( vuIvuRvuF

),(

),(tan),( 1

vuR

vuIvu

),(),(),(),( 222vuIvuRvuFvuP

Page 23: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Centering

Average gray level F(0,0) is called the dc component of the

spectrum

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

1

0

1

0

),(1

)0,0(M

x

N

y

yxfMN

F

Page 24: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Conjugate symmetric If f(x,y) is real

Relationships between samples in the spatial and frequency domains

),(*),( vuFvuF

),(),( vuFvuF

xMu

1

yNv

1

Page 25: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

The separation of spectrum zeros in the u-direction is exactly twice the separation of zeros in the v direction

Page 26: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Filtering in the frequency domain

Page 27: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Strong edges that run approximately at +45 degree, and -45 degree

The inclination off horizontal of the long white element is related to a vertical component that is off-axis slightly to the left

The zeros in the vertical frequency component correspond to the narrow vertical span of the oxide protrusions

Page 28: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Basics of filtering in the frequency domain 1. Multiply the input image by

to center the transform 2. Compute F(u,v) 3. Multiply F(u,v) by a filter function

H(u,v) 4. Compute the inverse DFT 5. Obtain the real part 6. Multiply the result by

yx )1(

yx )1(

Page 29: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Fourier transform of the output image

zero-phase-shift filter Real H(u,v)

),(),(),( vuFvuHvuG

),(

),(tan),( 1

vuR

vuIvu

Page 30: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Inverse Fourier transform of G(u,v)

The imaginary components of the inverse transform should all be zero When the input image and the filter

function are real

),(1 vuG

Page 31: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain
Page 32: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Set F(0,0) to be zero, a notch filter

otherwise1

)2/,2/(),( if0),(

NMvuvuH

Page 33: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain
Page 34: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Lowpass filter Pass low frequencies, attenuate high

frequencies Blurring

Highpass filter Pass high frequencies, attenuate low

frequencies Edges, noise

Page 35: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain
Page 36: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Convolution theorem

1

0

1

0

),(),(1

),(*),(M

m

N

n

nymxhnmfMN

yxhyxf

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

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

Page 37: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Impulse function of strength A

),( 00 yyxxA

),(),(),( 00

1

0

1

000 yxAsyyxxAyxs

M

x

N

y

)0,0(),(),(1

0

1

0

AsyxAyxsM

x

N

y

Page 38: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

MN

eyxMN

vuFM

x

N

y

NyvMxuj

1

),(1

),(1

0

1

0

)/ / (2

Page 39: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

),(1

),(),(1

),(*),(1

0

1

0

yxhMN

nymxhnmMN

yxhyxfM

m

N

n

Page 40: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

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

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

),(),( vuHyxh

Page 41: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Gaussian filter

22 2/)( uAeuH 22222)( xAexh

Page 42: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain
Page 43: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Highpass filter

22

221

2 2/2/)( uu BeAeuH 22

2222

12 2

22

1 22)( xx BeAexh

21 and BA

Page 44: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Smoothing Frequency-Domain Filterers

Ideal lowpass filters

),(),(),( vuFvuHvuG

0

0

Dv)D(u, if0

Dv)D(u, if1),( vuH

2/1 22 )2/()2/(),( NvMuvuD

Page 45: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain
Page 46: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Cutoff frequency

Total image power

Portion of the total power

0D

1

0

1

0

),(M

u

N

vT vuPP

u vTPvuP /),(100

Page 47: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain
Page 48: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain
Page 49: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Blurring and ringing properties Filter

Convolution

: Spatial filter was multiplied by Then the inverse DFT The real part of the inverse DFT was

multiplied by

),(),(),( vuFvuHvuG

),(*),(),( yxfyxhyxg ),( yxh

),( vuH vu )1(

yx )1(

Page 50: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain
Page 51: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

The filter A dominant component at the origin Concentric, circular components about

the center component --- ringing The radius of the center component

and the number of circles per unit distance from the origin are inversely proportional to the value of the cutoff frequency of the ideal filter.

),( yxh

Page 52: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Butterworth lowpass filters

when

nDvuDvuH 2

0/),(1

1),(

2/1 22 )2/()2/(),( NvMuvuD

5.0),( vuH 0),( DvuD

Page 53: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain
Page 54: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain
Page 55: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Butterworth lowpass filters Order 1: No ringing Order 2: Imperceptible ringing Higher order: Ringing becomes a

significant factor

Page 56: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain
Page 57: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Gaussain lowpass filters

When

No ringing

22 2/),(),( vuDevuH

2/1 22 )2/()2/(),( NvMuvuD

20

2 2/),(),( DvuDevuH

0D

Page 58: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain
Page 59: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain
Page 60: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Additional examples of lowpass filters Machine perception Printing and publishing Satellite and aerial images

Page 61: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain
Page 62: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain
Page 63: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain
Page 64: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Sharpening Frequency Domain Filters

Highpass filter

Spatial filter: was multiplied by Then the inverse DFT The real part of the inverse DFT was

multiplied by

),(1),( vuHvuH lphp

),( yxh),( vuH vu )1(

yx )1(

Page 65: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain
Page 66: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain
Page 67: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Ideal highpass filters

0

0

Dv)D(u, if1

Dv)D(u, if0),( vuH

2/1 22 )2/()2/(),( NvMuvuD

Page 68: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain
Page 69: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Butterworth highpass filters

nvuDDvuH 2

0 ),(/1

1),(

2/1 22 )2/()2/(),( NvMuvuD

Page 70: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain
Page 71: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Gaussian highpass filters

2/1 22 )2/()2/(),( NvMuvuD

20

2 2/),(1),( DvuDevuH

Page 72: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain
Page 73: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

The Laplacian in the frequency domain

)()()(

uFjudx

xfd nn

n

),()(

),()(),()(

),(),(

22

22

2

2

2

2

vuFvu

vuFjvvuFju

y

yxf

x

yxf

Page 74: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

)(),( 22 vuvuH

),()(),( 222 vuFvuyxf

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

After centering

Page 75: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Inverse Fourier transform

Fourier-transform pair

),()2/()2/(

),(221

2

vuFNvMu

yxf

),()2/()2/(

),(22

2

vuFNvMu

yxf

Page 76: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain
Page 77: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Subtracting the Laplacian from the original image

),( )2/()2/(1

),(221 vuFNvMu

yxg

),(),(),( 2 yxfyxfyxg

Page 78: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain
Page 79: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Unsharp masking, high-boost filtering, and high-frequency emphasis filtering Highpass filtering

High-boost filtering

),(),(),( yxfyxfyxf lphp

),(),(),( yxfyxAfyxf lphb

Page 80: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Frequency domain

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

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

),(1),( vuHvuH lphb

),()1(),( vuHAvuH hphb

Page 81: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain
Page 82: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

High-frequency emphasis

where and

),(),( vubHavuH hphfe

0a ab

Page 83: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain
Page 84: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Homomorphic Filtering

Illumination and reflectance components

Derivations

),(),(),( yxryxiyxf

),(),(),( yxryxiyxf

),(ln),(ln

),(ln),(

yxryxi

yxfyxz

Page 85: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Or

),(ln),(ln

),(ln),(

yxryxi

yxfyxz

),(),(),( vuFvuFvuZ ri

Page 86: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Frequency domain

Spatial domain

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

),(),(),(

vuFvuHvuFvuH

vuZvuHvuS

ri

),(),(

),(),(

),(),(

1

1

1

vuFvuH

vuFvuH

vuSyxs

r

i

Page 87: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

),(),(),(' 1 vuFvuHyxi i

),(),(),(' 1 vuFvuHyxr r

),('),('),( yxryxiyxs

),(),(

),(

00

),('),('),(

yxryxi

eeeyxg yxryxiyxs

Page 88: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Decrease the contribution made by the low frequencies (illumination)

Amplify the contribution made by high frequencies (reflectance)

Simultaneous dynamic range compression and contrast enhancement

Page 89: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

LDvuDc

LH evuH )/),(( 20

2

1)(),(

Page 90: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain
Page 91: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Implementation

Translation

When and

),(),( 00)//(2 00 vvuuFeyxf NyvMxuj

)//(200

00),(),( NvyMuxjevuFyyxxf

yx

yxjNyvMxuj ee

)1(

)()//(2 00

2/0 Mu 2/0 Nv

Page 92: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

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

vuvuFNyMxf )1)(,()2/,2/(

Page 93: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Distributivity and scaling

),(),(),(),( 2121 yxfyxfyxfyxf

),(),( vuaFyxaf

)/,/(1

),( bvauFab

byaxf

Page 94: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Rotation Polar coordinates

Rotating by an angle rotates by the same angle

cosrx sinry coswu sinwv

),(),( wFrf ),(),( 00 wFrf

),( yxf 0),( vuF

Page 95: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Periodicity and conjugate symmetry Periodicity property

),(),(

),(),(

NvMuFNvuF

vMuFvuF

),(),(

),(),(

NyMxfNyxf

yMxfyxf

Page 96: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Conjugate symmetry

Symmetry of the spectrum

),(),( * vuFvuF

),(),( vuFvuF

),(),( vuFvuF

),(),( vuFvuF

Page 97: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain
Page 98: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Separability

1

0

)/ (2

1

0

)/ v(21

0

)/ (2

1

0

1

0

)// (2

),(1

),(11

),(1

),(

M

x

Muxj

N

y

NyjM

x

Muxj

M

x

N

y

NvyMuxj

evxfM

eyxfN

eM

eyxfMN

vuF

Page 99: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

where

We can compute the 2-D transform by first computing a 1-D transform along each row of the input image, and then computing a 1-D transform along each column of this intermediate result

1

0

)/ v(2),(1

),(N

y

NyjeyxfN

vxF

Page 100: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain
Page 101: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Computing the inverse Fourier transform using a forward transform algorithm

1,...,2,1,0

,)(1

)(1

0

/ 2

Mu

exfM

uFM

x

Muxj

Page 102: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Calculate

1,...,2,1,0

,)()(1

0

/ 2

Mx

euFxfM

u

Muxj

1

0

/ 2** )(1

)(1 M

u

MuxjeuFM

xfM

Page 103: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

Inputting into an algorithm designed to compute the forward transform gives the quantity

)(* uF

)(1 * xfM

Page 104: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

2-D

1

0

1

0

)// (2*

*

),(1

),(1

M

u

N

v

NvyMuxjevuFMN

yxfMN

Page 105: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain

More on periodicity: the need for padding Convolution: Flip one of the functions

and slide it pass the other

1

0

)()(1

)()(M

m

mxhmfM

xhxf

Page 106: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain
Page 107: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain
Page 108: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain
Page 109: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain
Page 110: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain
Page 111: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain
Page 112: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain
Page 113: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain
Page 114: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain
Page 115: Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain