Transform ácie obrazu

70
Transformácie obrazu Gonzales, Woods: Digital Image Processing kapitola: Image transforms

description

Transform ácie obrazu. Gonzales, Woods: Digital Image Processing k apitola : Image transforms. Fourierova transformácia. Jean Baptiste Joseph Fourier (1768-1830) Akákoľvek funkcia f(x) môže byť vyjadrená ako vážený súčet sínusov a kosínusov. Suma s í nusov a kos ínusov. - PowerPoint PPT Presentation

Transcript of Transform ácie obrazu

Page 1: Transform ácie obrazu

Transformácie obrazu

Gonzales, Woods: Digital Image Processingkapitola: Image transforms

Page 2: Transform ácie obrazu

Fourierova transformácia

Jean Baptiste Joseph Fourier (1768-1830)

Akákoľvek funkcia f(x) môže byť vyjadrená ako vážený súčet sínusov a kosínusov

Page 3: Transform ácie obrazu

Suma sínusov a kosínusov

A sin(ωx+φ)

Page 4: Transform ácie obrazu

Time and Frequency

example : g(t) = sin(2πf t) + (1/3)sin(2π(3f) t)

Page 5: Transform ácie obrazu

Time and Frequency

example : g(t) = sin(2πf t) + (1/3)sin(2π(3f) t)

= +

Page 6: Transform ácie obrazu

Frequency Spectra

example : g(t) = sin(2πf t) + (1/3)sin(2π(3f) t)

= +

Page 7: Transform ácie obrazu

Frequency Spectra

Page 8: Transform ácie obrazu

= +

=

Frequency Spectra

Page 9: Transform ácie obrazu

= +

=

Frequency Spectra

Page 10: Transform ácie obrazu

= +

=

Frequency Spectra

Page 11: Transform ácie obrazu

= +

=

Frequency Spectra

Page 12: Transform ácie obrazu

= +

=

Frequency Spectra

Page 13: Transform ácie obrazu

= 1

1sin(2 )

k

A ktk

Frequency Spectra

Page 14: Transform ácie obrazu

Frequency Spectra

Page 15: Transform ácie obrazu

FT: Just a change of basis

.

.

.

* =

M * f(x) = F(w)

Page 16: Transform ácie obrazu

IFT: Just a change of basis

.

.

.

* =

M-1 * F(w) = f(x)

Page 17: Transform ácie obrazu
Page 18: Transform ácie obrazu

Fourierova transformáciaAk f(x) je spojitá funkcia s reálnou premenou x,potom Fourierovou transformáciou F(x) je

Inverznou Fourierovou transformáciou nazývame

pár Fourierovej transformácie

Page 19: Transform ácie obrazu

Fourier Transform

uxAsin(

f(x) F(u)Fourier Transform

F(u) f(x)Inverse Fourier Transform

Pre každé u od 0 po inf, F(u) obsahuje amplitudu A and fázu f odpovedajúceho sinusu

22 )()( uIuRA )(

)(tan 1

uR

uI

Page 20: Transform ácie obrazu

Definitions F(u) sú komplexne čísla:

Magnitúda FT (spektrum):

Fázový uhol FT:

Reprezentácia pomocou magnitúdy a fázy:

Power of f(x): P(u)=|F(u)|2=

Page 21: Transform ácie obrazu

FT – je periodická s periódou N, to znamená, že na jej určenie stačí jedna perióda vo frekvenčnej oblasti.

Page 22: Transform ácie obrazu

2D Fourierova transformácia

Fourierova transformáci je ľahko rozšíriteľná do 2D

Page 23: Transform ácie obrazu
Page 24: Transform ácie obrazu

Príklad 2D funkcie

Page 25: Transform ácie obrazu
Page 26: Transform ácie obrazu
Page 27: Transform ácie obrazu
Page 28: Transform ácie obrazu
Page 29: Transform ácie obrazu
Page 30: Transform ácie obrazu
Page 31: Transform ácie obrazu
Page 32: Transform ácie obrazu
Page 33: Transform ácie obrazu

Sinusoidové vzory sa zobrazia vo frekvenčnom spektre ako body.

Page 34: Transform ácie obrazu

Nízke frekvencie sú pri strede a vysoké na okrajoch

Page 35: Transform ácie obrazu
Page 36: Transform ácie obrazu
Page 37: Transform ácie obrazu

Sampling Theorem

Continuous signal:

Shah function (Impulse train):

xf

x

Sampled function:

n

s nxxxfxsxfxf 0

xs

x0x

n

nxxxs 0

Page 38: Transform ácie obrazu

Sampling

Page 39: Transform ácie obrazu

Sampling and the Nyquist rate

Pri vzorkovaní spojitej funkcie môže vzniknúť aliasing ak vzorkovacia frekvencia nie je dostatočne vysoká

Vzorkovacia frekvencia musí byť taká vysoká aby zachytila aj tie najvyššie frekvencie obrazu

Page 40: Transform ácie obrazu

Predísť aliasingu: Vzorkovacia frekvencia > 2 * max

frekvencia v obraze Treba viac ako 2 vzorky na periódu Minimálna vzorkovacia frekvencia

sa nazýva Nyquist rate

Sampling and the Nyquist rate

Page 41: Transform ácie obrazu

Diskrétna Fourierova transformácia

Page 42: Transform ácie obrazu

Rozšírenie DFT do 2D

Predpokladajme že f(x,y) je M x N.

DFT

Inverzná DFT:

Page 43: Transform ácie obrazu

Filtre

Page 44: Transform ácie obrazu

Vizualizácia DFT Väčšinou zobrazujeme |F(u,v)| Dynamický rozsah |F(u,v)| je obvykle

veľmi vysoký

Aplikujeme logaritmus:

(c je konštanta)

before scaling after scalingoriginal image

Page 45: Transform ácie obrazu

DFT Properties: (1) Separability

The 2D DFT can be computed using 1D transforms only:

Forward DFT:

Inverse DFT:

2 ( ) 2 ( ) 2 ( )ux vy ux vy

j j jN N Ne e e

kernel isseparable:

Page 46: Transform ácie obrazu

DFT Properties: (1) Separability

Rewrite F(u,v) as follows:

Let’s set:

Then:

Page 47: Transform ácie obrazu

How can we compute F(x,v)?

How can we compute F(u,v)?

DFT Properties: (1) Separability

)

N x DFT of rows of f(x,y)

DFT of cols of F(x,v)

Page 48: Transform ácie obrazu

DFT Properties: (1) Separability

Page 49: Transform ácie obrazu

DFT Properties: (2) Periodicity

The DFT and its inverse are periodic with period N

Page 50: Transform ácie obrazu

DFT Properties: (3) Symmetry

• If f(x,y) is real, then

Page 51: Transform ácie obrazu

DFT Properties: (4) Translation

f(x,y) F(u,v)

) N

• Translation is spatial domain:

• Translation is frequency domain:

Page 52: Transform ácie obrazu

DFT Properties: (4) Translation

Page 53: Transform ácie obrazu

DFT Properties: (4) Translation

Warning: to show a full period, we need to translate the origin of the transform at u=N/2 (or at (N/2,N/2) in 2D)

|F(u-N/2)|

|F(u)|

Page 54: Transform ácie obrazu

DFT Properties: (4) Translation

To move F(u,v) at (N/2, N/2), take

Using ) N

Page 55: Transform ácie obrazu

DFT Properties: (4) Translation

no translation after translation

Page 56: Transform ácie obrazu

DFT Properties: (5) Rotation

Otočením f(x,y) o uhol θ, sa otočí F(u,v) o ten istý uhol θ

Page 57: Transform ácie obrazu

DFT Properties: (6) Addition/Multiplication

but …

Page 58: Transform ácie obrazu

DFT Properties: (7) Scale

Page 59: Transform ácie obrazu

DFT Properties: (8) Average value

So:

Average:

F(u,v) at u=0, v=0:

Page 60: Transform ácie obrazu

Magnitude and Phase of DFT

What is more important?

Hint: use inverse DFT to reconstruct the image using magnitude or phase only information

magnitude phase

Page 61: Transform ácie obrazu

Magnitude and Phase of DFT

Reconstructed image using magnitude only(i.e., magnitude determines the contribution of each component!)

Reconstructed image using phase only(i.e., phase determineswhich components are present!)

Page 62: Transform ácie obrazu

Magnitude and Phase of DFT

Page 63: Transform ácie obrazu

Výpočtová náročnosť DFT

{f0, f1, ... , fN-1} – vstupná body{F0, F1, ... , FN-1} – výsledok Fourierovej transformácie

Výpočet pomocou 2 cyklov – > zložitosť O(N2)

Snaha zredukovať na O(Nlog2N) – > FFT

discrete Fourier transform — DFT

Page 64: Transform ácie obrazu

Fast Fourier Transform - FFT

Pre N=8

Rozdelíme na párne a nepárne členy

Urobíme to isté vo zátvorkách

Page 65: Transform ácie obrazu

Suma vo vnútorných zátvorkách je rovnaká pre n=0, 2, 4, 6 a pre n=1, 3, 5, 7

Takže máme 4 (zátvorky) x 2 súčtov na najnižšej úrovniKeďže n=1, 3, 5, 7 zodpovedá polovici periódy П a platídostaneme 1 pre n=0, 2, 4, 6 a

- 1 pre n=1, 3, 5, 7

Page 66: Transform ácie obrazu

V hranatých zátvorkách je perióda exponentu n=4 – > n=0, 4; n=1, 5; n=2, 6 a n=3, 7.

Pre n=0, 4 factor je 1 pre n=2, 6 je to -1; pre n=1, 5 je -i a pre n=3, 7 je i.

Takže máme 2 (zátvorky) x 4 súčtov na strednej úrovni

Page 67: Transform ácie obrazu

Na najvyššej úrovni máme 1 sumu a periódu exponentu n=8– > 1 x 8 súčtovPolovicu z nich môžeme vypočítať iba zmenou znamienkaNa každej úrovni urobíme 8 operácií (n)Máme 3 = log 8 úrovne (log n)

O( n log n )

Page 68: Transform ácie obrazu

FFT - algoritmus

Prepare input data for summation — put them into convenient order;For every summation level:

For every exponent factor of the half-period: Calculate factor;For every sum of this factor:

Calculate product of the factor and the second term of the sum;Calculate sum;

{f0, f1, f2, f3, f4, f5, f6, f7}→{f0, f4, f2, f6, f1, f5, f3, f7}.

Page 69: Transform ácie obrazu

Poradie koeficientov pre FFT

0 000 000 000 0

1 001 010 100 4

2 010 100 010 2

3 011 110 110 6

4 100 001 001 1

5 101 011 101 5

6 110 101 011 3

7 111 111 111 7

Page 70: Transform ácie obrazu

Príklad pre N=16