practical image processing1 chap7 image transformation image and transformed image spatial...

36
Practical Image Processing 1 Chap7 Image Transformation Image and Transformed image Image and Transformed image Spatial --------------------- Spatial --------------------- Transformed Transformed domain domain Transformation Transformation domain domain h(x,y) Fourier, DCT Fourier, DCT F(u,v) Processing in the transformed Processing in the transformed domain : domain : Filtering, Compression, Description Filtering, Compression, Description Fourier transform : 1807 Fourier Fourier transform : 1807 Fourier any periodic signal can be represented as any periodic signal can be represented as a weighted sum of sinusoids a weighted sum of sinusoids

Upload: suzan-carroll

Post on 18-Jan-2016

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Practical Image Processing1 Chap7 Image Transformation  Image and Transformed image Spatial ---------------------  Transformed domain Transformation

Practical Image Processing 1

Chap7 Image Transformation

Image and Transformed imageImage and Transformed imageSpatial ---------------------Spatial --------------------- Transformed Transformeddomain domain Transformation Transformation domain domain h(x,y) Fourier, DCTFourier, DCT F(u,v)

Processing in the transformed domain :Processing in the transformed domain : Filtering, Compression, DescriptionFiltering, Compression, Description

Fourier transform : 1807 FourierFourier transform : 1807 Fourier any periodic signal can be represented as a any periodic signal can be represented as a

weighted sum of sinusoidsweighted sum of sinusoids

Page 2: Practical Image Processing1 Chap7 Image Transformation  Image and Transformed image Spatial ---------------------  Transformed domain Transformation

Practical Image Processing 2

Page 3: Practical Image Processing1 Chap7 Image Transformation  Image and Transformed image Spatial ---------------------  Transformed domain Transformation

Practical Image Processing 3

spatial frequency of an image refers to the spatial frequency of an image refers to the rate at which pixel intensities changerate at which pixel intensities change

dxdyeyxhvuH vyuxj )(2),(),(

dudvevuHyxh vyuxj )(2),(),(

anglePhasevuR

vuIvu

SpectrumFouriervuIvuRvuH

vujIvuRvuHLet

exjxej jxjx

:),(

),(tan),(

:),(),(),(

),(),(),(

1,sincos,1

1

22

Page 4: Practical Image Processing1 Chap7 Image Transformation  Image and Transformed image Spatial ---------------------  Transformed domain Transformation

Practical Image Processing 4

H(u,v); H(u,v); u : spatial frequency along x axisu : spatial frequency along x axis v : spatial frequency along y axisv : spatial frequency along y axis

Page 5: Practical Image Processing1 Chap7 Image Transformation  Image and Transformed image Spatial ---------------------  Transformed domain Transformation

Practical Image Processing 5

Discrete Fourier Transform (DFT)Discrete Fourier Transform (DFT) let h(x,y) be an M x N imagelet h(x,y) be an M x N image

Inverse Discrete Fourier Transform(IDFT)Inverse Discrete Fourier Transform(IDFT)

1

0

1

0

)(2),(

1),(

M

x

N

y

Nvy

Muxj

eyxhMN

vuH

1

0

1

0

)(2),(),(

M

x

N

y

Nvy

Muxj

evuHyxh

Page 6: Practical Image Processing1 Chap7 Image Transformation  Image and Transformed image Spatial ---------------------  Transformed domain Transformation

Practical Image Processing 6

Sample code for DFT

input : double h[M][N]

output : COMPLEX H[M][N]

for (u=0; u<M; u++)

for (v=0; v<N; v++) {

sum_re = 0; sum_im = 0;

cu = 2*3.14159*u/M;

cv=2*3.14159*v/N;

for (x=0; x<M; x++)

for (y=0; y<N; y++) {

theta = x*cu + y*cv;

sum_re += h[x][y] * cos(theta);

sum_im -= h[x][y] * sin(theta);

}

H[u][v].re = sum_re;

H[u][v].im = sum_im;

}

struct {

double re; double im;} COMPLEX;

Page 7: Practical Image Processing1 Chap7 Image Transformation  Image and Transformed image Spatial ---------------------  Transformed domain Transformation

Practical Image Processing 7

DFT expects input to be periodic DFT expects input to be periodic

Page 8: Practical Image Processing1 Chap7 Image Transformation  Image and Transformed image Spatial ---------------------  Transformed domain Transformation

Practical Image Processing 8

Gibbs phenomenon Gibbs phenomenon ringing effect caused by sampling & ringing effect caused by sampling &

truncationtruncation can reduce width of ringing by increasing can reduce width of ringing by increasing

the number of data samplesthe number of data samples amplitude of ringing is proportional to amplitude of ringing is proportional to

difference between amplitude of first and difference between amplitude of first and last samplelast sample can reduce it by multiplying data by windowing can reduce it by multiplying data by windowing

functionfunction

skipskip

Page 9: Practical Image Processing1 Chap7 Image Transformation  Image and Transformed image Spatial ---------------------  Transformed domain Transformation

Practical Image Processing 9skip

Page 10: Practical Image Processing1 Chap7 Image Transformation  Image and Transformed image Spatial ---------------------  Transformed domain Transformation

Practical Image Processing 10

window functions attenuate values at truncation edgeswindow functions attenuate values at truncation edges

Page 11: Practical Image Processing1 Chap7 Image Transformation  Image and Transformed image Spatial ---------------------  Transformed domain Transformation

Practical Image Processing 11

Fast Fourier transformFast Fourier transform for NxN image, time complexity of DFT isfor NxN image, time complexity of DFT is

O(NO(N44)) fast algorithm : Bell lab 1965fast algorithm : Bell lab 1965 adopt divide and conquer technique for fast adopt divide and conquer technique for fast

computation : O(Ncomputation : O(N22logN)logN)19 hours 19 hours 4.8 sec : table 7.2 4.8 sec : table 7.2

dimension of image must be powers of 2dimension of image must be powers of 2 expand to legal size by zero-paddingexpand to legal size by zero-padding

Page 12: Practical Image Processing1 Chap7 Image Transformation  Image and Transformed image Spatial ---------------------  Transformed domain Transformation

Practical Image Processing 12

(1) bit-reversal operation : (1) bit-reversal operation : skipskip

Page 13: Practical Image Processing1 Chap7 Image Transformation  Image and Transformed image Spatial ---------------------  Transformed domain Transformation

Practical Image Processing 13

skipskip exploit periodicity and symmetry of recursive exploit periodicity and symmetry of recursive

DFT computationDFT computation swap data elements for in-place computationswap data elements for in-place computation

butterflies operationbutterflies operation

divide set of data points down and perform divide set of data points down and perform series of 2 points DFTseries of 2 points DFT

Page 14: Practical Image Processing1 Chap7 Image Transformation  Image and Transformed image Spatial ---------------------  Transformed domain Transformation

Practical Image Processing 14

how to display frequency datahow to display frequency data 1 pixel range : 1 cycle1 pixel range : 1 cycle

small u, v : low frequencysmall u, v : low frequency

logarithmic transform : wide dynamic rangelogarithmic transform : wide dynamic rangeD(u,v) = c log(1+|H(u,v)|)D(u,v) = c log(1+|H(u,v)|)

unordered vs ordered display(centering)unordered vs ordered display(centering)

I

IVIII

II IV

III

III

1

0

1

0

)(2),(

1),(

M

x

N

y

Nvy

Muxj

eyxhMN

vuH

Page 15: Practical Image Processing1 Chap7 Image Transformation  Image and Transformed image Spatial ---------------------  Transformed domain Transformation

Practical Image Processing 15

Page 16: Practical Image Processing1 Chap7 Image Transformation  Image and Transformed image Spatial ---------------------  Transformed domain Transformation

Practical Image Processing 16

Magnitude only

+

Phase

Page 17: Practical Image Processing1 Chap7 Image Transformation  Image and Transformed image Spatial ---------------------  Transformed domain Transformation

Practical Image Processing 17

Page 18: Practical Image Processing1 Chap7 Image Transformation  Image and Transformed image Spatial ---------------------  Transformed domain Transformation

Practical Image Processing 18

Fourier,

Logarithmic

PartialInverse

Fourier

Page 19: Practical Image Processing1 Chap7 Image Transformation  Image and Transformed image Spatial ---------------------  Transformed domain Transformation

Practical Image Processing 19

Page 20: Practical Image Processing1 Chap7 Image Transformation  Image and Transformed image Spatial ---------------------  Transformed domain Transformation

Practical Image Processing 20

Page 21: Practical Image Processing1 Chap7 Image Transformation  Image and Transformed image Spatial ---------------------  Transformed domain Transformation

Practical Image Processing 21

Filtering in Frequency Domain

convolution in spatial domain == multiplicaticonvolution in spatial domain == multiplication in frequency domainon in frequency domain transform into frequency domain by FFTtransform into frequency domain by FFT

f(x, y) f(x, y) F(u, v). pgm : list 7.1 F(u, v). pgm : list 7.1

multiply by filtering mask in frequency domainmultiply by filtering mask in frequency domain G(u, v) = H(u, v) F(u, v). pgm : list 7.2G(u, v) = H(u, v) F(u, v). pgm : list 7.2 H(u, v) : filterH(u, v) : filter

transform back to spatial domain by IFFTtransform back to spatial domain by IFFT G(u, v) G(u, v) g(x, y) g(x, y)

Page 22: Practical Image Processing1 Chap7 Image Transformation  Image and Transformed image Spatial ---------------------  Transformed domain Transformation

Practical Image Processing 22

F(u,v)

f(x,y)

H(u,v)

H(u,v)F(u,v)

g(x,y)

Page 23: Practical Image Processing1 Chap7 Image Transformation  Image and Transformed image Spatial ---------------------  Transformed domain Transformation

Practical Image Processing 23

Ideal Filters filters : low-pass, high-pass, band-pass, band-stopfilters : low-pass, high-pass, band-pass, band-stop ideal filter : pass, not-pass style ideal filter : pass, not-pass style

Page 24: Practical Image Processing1 Chap7 Image Transformation  Image and Transformed image Spatial ---------------------  Transformed domain Transformation

Practical Image Processing 24

Ideal Low Pass Filter

Page 25: Practical Image Processing1 Chap7 Image Transformation  Image and Transformed image Spatial ---------------------  Transformed domain Transformation

Practical Image Processing 25

Ideal Low Pass Filter : Example

Input image500x500

H(u,v) with D0 : 5, 15, 30, 80, 230

D0 = 5

D0 = 30

D0 = 230D0 = 80

D0 = 15

Ringing 현상 나타남

Page 26: Practical Image Processing1 Chap7 Image Transformation  Image and Transformed image Spatial ---------------------  Transformed domain Transformation

Practical Image Processing 26

Practical Low Pass Filter : Butterworth

ideal filters cause blurring & ringing in spatial domainideal filters cause blurring & ringing in spatial domain use Butterworth filter for smooth frequency responseuse Butterworth filter for smooth frequency response Low Pass Filter : (== blurring, smoothing mask)Low Pass Filter : (== blurring, smoothing mask)

nDvuDvuH

20 ]/),([1

1),(

D0 : cutoff frequency

n : order

Page 27: Practical Image Processing1 Chap7 Image Transformation  Image and Transformed image Spatial ---------------------  Transformed domain Transformation

Practical Image Processing 27

Butterworth Low Pass Filter : Example

Input image500x500

H(u,v) with D0 : 5, 15, 30, 80, 230

D0 = 5

D0 = 30

D0 = 230D0 = 80

D0 = 15

Ringing 현상 안 나타남

Page 28: Practical Image Processing1 Chap7 Image Transformation  Image and Transformed image Spatial ---------------------  Transformed domain Transformation

Practical Image Processing 28

Page 29: Practical Image Processing1 Chap7 Image Transformation  Image and Transformed image Spatial ---------------------  Transformed domain Transformation

Practical Image Processing 29

D0=

1/3

D0=

1/2

Ideal

lowpass filters

Page 30: Practical Image Processing1 Chap7 Image Transformation  Image and Transformed image Spatial ---------------------  Transformed domain Transformation

Practical Image Processing 30

D0=

1/3

D0=

1/2

ideal

Butterworth

Page 31: Practical Image Processing1 Chap7 Image Transformation  Image and Transformed image Spatial ---------------------  Transformed domain Transformation

Practical Image Processing 31

Ideal High Pass Filter

Page 32: Practical Image Processing1 Chap7 Image Transformation  Image and Transformed image Spatial ---------------------  Transformed domain Transformation

Practical Image Processing 32

Ideal High Pass Filter : Example

IHPFD0 = 15

IHPFD0 = 30

IHPFD0 = 80

Input Image500 x 500

Page 33: Practical Image Processing1 Chap7 Image Transformation  Image and Transformed image Spatial ---------------------  Transformed domain Transformation

Practical Image Processing 33

ButterWorth HPFThe Butterworth high pass filter is given as:The Butterworth high pass filter is given as:

where where nn is the order and is the order and DD00 is the cut off is the cut off

distance as beforedistance as before

nvuDDvuH

20 )],(/[1

1),(

Page 34: Practical Image Processing1 Chap7 Image Transformation  Image and Transformed image Spatial ---------------------  Transformed domain Transformation

Practical Image Processing 34

Butterworth HPF : Example

D0 = 15 D0 = 30 D0 = 80

Page 35: Practical Image Processing1 Chap7 Image Transformation  Image and Transformed image Spatial ---------------------  Transformed domain Transformation

Practical Image Processing 35

High Pass Filter : sharpeningHigh Pass Filter : sharpening

Band Pass FilterBand Pass Filter pass specific frequency component onlypass specific frequency component only

W : bandwidth, DW : bandwidth, D00 : center freqency : center freqency

.:uv)D(u,

),(1

1),( 22

20

FreqCutoffv

vuD

DvuH

n

),(

),(1

1),(

2

20

2

n

DvuD

WvuDvuH

Page 36: Practical Image Processing1 Chap7 Image Transformation  Image and Transformed image Spatial ---------------------  Transformed domain Transformation

Practical Image Processing 36

Discrete Cosine Transform(DCT)

produce real frequency coefficientsproduce real frequency coefficients fast : pgm list 7.2, 7.3fast : pgm list 7.2, 7.3 used for image compression : JPEG, MPEGused for image compression : JPEG, MPEG

otherwiseforCHere

N

vy

M

uxvuHvCuC

MNyxh

M

u

N

v

1,02/1)(

2

)12(cos

2

)12(cos),()()(

2),(

1

0

1

0

1

0

1

0 2

)12(cos

2

)12(cos),()()(

2),(

M

u

N

v N

vy

M

uxyxhvCuC

MNvuH