Download as pdf or txt
Download as pdf or txt
You are on page 1of 27

Image Analysis Exercise 1:

Fourier Descriptors
(Due 13.11.2009)
The Discrete Fourier Transform in
The Discrete Fourier Transform in
MATLAB (1)
MATLAB (1)
DFT
IDFT
Frequancy domain
(complex spectrum)
Time domain
(complex signal)
Signal
Reconstructe !rom
t"e spectrum A(m) .
Spectrum
#re$uency omain
representation.
%eig"t an p"ase o!
!re$uency .
Basis Function
&omplex exponential(oscillation).
#re$uency m/N o'er entire signal
0 x < N .
Forward DFT
(MATLAB fft)
Inverse DFT
(MATLAB ifft)
The Discrete Fourier Transform in
The Discrete Fourier Transform in
MATLAB (2)
MATLAB (2)
...
Real
Imaginary
The Discrete Fourier Transform in
The Discrete Fourier Transform in
MATLAB (4)
MATLAB (4)

#or(ar trans!orm: fft (fft2 !or 2D signals)

In'erse trans!orm: ifft (ifft2 !or 2D signals)

)"e trans!orms a"ere strictly to t"e e!inition o! t"e D#)

)"e *ero !re$uency (D& component) is at A(0)

)"e +A),A- !unction fftshift centres t"e spectrum

,argest .e!!ecti'e/ negati'e !re$uency in A(0)

,argest .e!!ecti'e/ positi'e !re$uency in A(N-1)

ifftshift re'erses t"e e!!ects o! fftshift


plot(g); abs(fft(g)) abs(fftshift(fft(g)))
Fourier Descriptors: Overview
Fourier Descriptors: Overview
.
.
.
.
.
.

&oncise an escription o! (o01ect) contours

&ontours are represente 0y 'ectors

2umerous application

&ontour 3rocessing (!iltering4 interpolation4 morp"ing)

Image analysis: &"aracterising an recognising t"e s"apes o! o01ect


epresentin! a "ontour usin! the DFT
epresentin! a "ontour usin! the DFT
.
.
.
.
.
.
(x
2
4y
2
): &oorinates o!
t"e 2
t"
point along t"e
circum!erence
3ixels on t"e contour are
assume to 0e orere (e.g.
cloc5(ise)6
De!ine a complex 'ector
using coorinates (x4y).
1
st
Step
2
nd
Step
Apply t"e 1D D#)
"ontour #rocessin!
"ontour #rocessin!

In t"is example4 a contour is processe using a lo(7pass !ilter

8t"er !ilters: 9"arpening4 Ege extraction4 ...

+orp"ing contours an interpolation are also easily ac"ie'e


Fourier Descriptors in $ma!e Ana%&sis
Fourier Descriptors in $ma!e Ana%&sis

801ect Recognition using s"ape in!ormation

Appropriate pre7processing steps ma5e #ourier Descriptors in'ariant to common


trans!ormations

)ranslation4 c"anges in scale4 rotation

)"e contour o! a 5no(n o01ect can t"ere!ore 0e recognise irrespecti'ely o! its position4
si*e an orientation
1. Data0ase (it" 5no(n
o01ect types
2. Extraction o!
o01ect contours
...
3. &omputation o! in'ariant
#ourier Descriptors
F F
1. Image (it"
un5no(n o01ects
2. Extraction o! o01ect contours
an in'ariant escriptors
...
F F
3. Recognition 0y
comparison (it" ata0ase
App%ica
App%ica
tion: eco!nisin! an' c%assif&in!
tion: eco!nisin! an' c%assif&in!
%eaves
%eaves
Database
)(o types o! lea'es are to 0e
recognise an classi!ie
App%ica
App%ica
tion: eco!nisin! an' c%assif&in!
tion: eco!nisin! an' c%assif&in!
%eaves
%eaves
Image (it" unclassi!ie o01ects
App%ica
App%ica
tion: eco!nisin! an' c%assif&in!
tion: eco!nisin! an' c%assif&in!
%eaves
%eaves
9egmente 801ects
()"res"oling)
App%ica
App%ica
tion: eco!nisin! an' c%assif&in!
tion: eco!nisin! an' c%assif&in!
%eaves
%eaves
,ea'es etecte an classi!ie
Trans%ation
Trans%ation
t
t
)ranslating U 0y t:

Derivation (Trans%ation)
Derivation (Trans%ation)
= 0:
> 0:
(9ummation o'er
perioic signal6)
All in!ormation regaring (glo0al) translation is containe in element 0 o! t"e escriptor

"han!es in (ca%e
"han!es in (ca%e
+agni!ication 0y !actor s:
Derivation ("han!es in (ca%e)
Derivation ("han!es in (ca%e)

otation
otation
Rotation 0y an angle :
(Deri'ation ientical to scale c"ange: +ultiplication 0y constant)
(tartin! point
(tartin! point
Di!!erent staring points a!!ect t"e orer o! elements in U an t"e F o0taine.
&"anging t"e starting point 0y m places (pixels):
Derivation
Derivation
((tartin! #oint an' Mirrorin!)
((tartin! #oint an' Mirrorin!)

9"i!ting t"e starting point 0y m places (pixels)

+irroring t"e contour (le!t:rig"t or top:0ottom or cloc5(ise:anticloc5(ise)


(; inicates complex con1ugation)
)orma%isation (1)
)orma%isation (1)

Translation Invariance: &entre t"e contour at t"e origin


Translation by t:
9cale c"ange 0y s:

Scale Invariance: 9tanarise t"e si*e o! t"e contour


()"e 0 !re$uency contains all an only t"e in!ormation relate to translation)
&onsier: t"en
)orma%isation (2)
)orma%isation (2)

Rotation an changes in starting point: A!!ect only t"e p"ase o! t"e escriptor

9imple 9olution: 9imply remo'e all p"ase in!ormation

&onsier only a0solute 'alues o! t"e escriptor elements:


Rotation 0y angle :
+o'ing t"e starting point 0y m places:
But:
(In!ormation loss4 0ot" s"apes "a'e t"e same amplitue spectrum)

*+ercises

function plotFD(F)

F: )"e (non7normalise) #ourier escriptor o! a contour

3lots t"e contour U escri0e 0y F

(2ote: t"e +A),A- plot comman also accepts complex num0ers)

function [G]=shiftFD(F, x, y)

F: )"e (non7normalise) #ourier escriptor o! a contour

x: <7)ranslation

y: =7)ranslation

G: )"e (non7normalise) #ourier escriptor o! t"e s"i!te contour

)ranslates t"e contour corresponing to F 0y (X,Y) 3ixels

)"is operation oes not re$uire an (in'erse) D#)6

function [G]=scaleFD(F,scaleFactor)

F: )"e (non7normalise) #ourier escriptor o! a contour

scaleFactor: &"ange in contour scale

G: )"e (non7normalise) #ourier escriptor o! t"e scale contour

9cales t"e contour corresponing to F 0y 100*scaleFactor >.

)"is operation oes not re$uire an (in'erse) D#)6


function [G]=resizeFD(F, n)

F: )"e #ourier escriptor o! a contour

G: )"e a resi*e #ourier escriptor (it" n elements

3rocesses F to o0tain G, ("ic" "as 0een s"ortene to contain only n elements (assume F
"as more t"an n elements).

?se fftshift to mo'e "ig" @e!!ecti'e. !re$uencies to t"e 0eginning an en o! F

Remo'e elements !rom 0eginning an en until t"e lengt" e$uals n.

function [G]=normaliseFD(F)

F: )"e (non7normalise) #ourier escriptor o! a contour

G: )"e normalise4 in'ariant #ourier escriptor o! t"e contour

3rocesses F to o0tain G4 ("ic" is in'ariant to translation4 rotation an scaling o! t"e


original contour.

function [diff]=compareFD(F, G)

F: 2ormalise4 in'ariant #ourier escriptor

G: 2ormalise4 in'ariant #ourier escriptor

diff: A measure of te differen!e between F an G

Auanti!ies t"e i!!erence 0et(een F an G (see lecture notes)


function [F]=extractFD(U)

U: A 'ector o! complex pixel coorinates on t"e contour o! an o01ect (in


arbitrary order!

F: )"e non7normalise #ourier Descriptor o! t"e contour

Extracts t"e #ourier Descriptor o! a contour4 escri0e 0y a 'ector o! coorinates

)"e 'ector must 0e sorte 0e!ore !urt"er processing (+A),A- !unction sort)

)"e orer o! pixels can 0e etermine using t"e irection4 or angle4 !rom t"e
o01ect centre to eac" pixel (assume mostly con'ex o01ects).
eco!nisin! an' "%assif&in! Leaves
eco!nisin! an' "%assif&in! Leaves
(Trainin! #hase)
(Trainin! #hase)

,oa t"e example grayscale images !or 0ot" types o! lea! an segment t"em using a
t"res"ol

)"e t"res"ol can 0e a constant4 etermine empirically

)"res"oling in +A),A- is a single line o! coe6 (,ogical 8perator)

)"e resulting images "a'e t"e 'alue o! 1 (true) insie lea'es4 an 0 (!alse) outsie.

Extract t"e one7pixel t"ic5 contour o! t"e segmente lea'es

?se morp"ological operators (i.e. +A),A- !unctions imerode/imdilate)

?se extractFD,normaliseFD an4 !inally4 resizeFD to c"aracterise 0ot" types o!


lea! 0y t(o in'ariant #ourier Descriptors o! e$ual lengt"
)"e !ollo(ing approac" to recognition an classi!ication is to 0e
implemente in one4 or se'eral (0etter)4 +A),A- !unctions
eco!nisin! an' "%assif&in! Leaves
eco!nisin! an' "%assif&in! Leaves
("%assification #hase)
("%assification #hase)

,oa t"e grayscale test image an segment it 0y t"res"oling

)"e result is a 0inary image in ("ic" lea'es4 0ranc"es an ot"er o01ects are
assigne 1 (true) an t"e 0ac5groun is 0 (!alse)

?se a morp"ological operator to separate lea'es !rom 0ranc"es an ot"er o01ects


(e.g. +A),A- !unction imopen)

Extract t"e one7pixel t"ic5 contour o! t"e remaining o01ects

+orp"ological operators again

Enumerate t"e o0taine contours o! o01ects using t"e +A),A- !unction bwlabel

#or eac" contour:

Determine t"e coorinates o! pixels on t"e contour using find

Extract an in'ariant escription ((it" a stanar lengt") o! t"e contour using


extractFD, normaliseFD an resizeFD, an use compareFD to
compare t"e escription to 0ot" types o! lea!

Assign t"e contour to t"e more similar type o! lea!

3lot t"e classi!ie contours4 using colour to inicate t"e classi!ication result.

You might also like