University of Ioannina - Department of Computer Science Filtering in the Frequency Domain...

60
University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou [email protected]

Transcript of University of Ioannina - Department of Computer Science Filtering in the Frequency Domain...

Page 1: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

University of Ioannina - Department of Computer Science

Filtering in the Frequency Domain(Fundamentals)

Digital Image Processing

Christophoros Nikou

[email protected]

Page 2: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

2

C. Nikou – Digital Image Processing (E12)

Filtering in the Frequency Domain

Filter: A device or material for suppressing or minimizing waves or oscillations of certain frequencies.

Frequency: The number of times that a periodic function repeats the same sequence of values during a unit variation of the independent variable.

Webster’s New Collegiate Dictionary

Page 3: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

3

C. Nikou – Digital Image Processing (E12)

Jean Baptiste Joseph Fourier

Fourier was born in Auxerre, France in 1768.

– Most famous for his work “La Théorie Analitique de la Chaleur” published in 1822.

– Translated into English in 1878: “The Analytic Theory of Heat”.

Nobody paid much attention when the work was first published.One of the most important mathematical theories in modern engineering.

Page 4: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

4

C. Nikou – Digital Image Processing (E12)

The Big Idea

=

Any function that periodically repeats itself can be expressed as a sum of sines and cosines of different frequencies each multiplied by a different coefficient – a Fourier series

Ima

ge

s ta

ken

fro

m G

on

zale

z &

Wo

od

s, D

igita

l Im

ag

e P

roce

ssin

g (

20

02

)

Page 5: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

5

C. Nikou – Digital Image Processing (E12)

1D continuous signalsIm

ag

es

take

n f

rom

Go

nza

lez

& W

oo

ds,

Dig

ital I

ma

ge

Pro

cess

ing

(2

00

2)

00

,( )

0 otherwise

x xx x

• It may be considered both as continuous and discrete.

• Useful for the representation of discrete signals through sampling of continuous signals.

0 0( ) ( ) ( )f x x x dx f x

Page 6: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

6

C. Nikou – Digital Image Processing (E12)

1D continuous signals (cont.)Im

ag

es

take

n f

rom

Go

nza

lez

& W

oo

ds,

Dig

ital I

ma

ge

Pro

cess

ing

(2

00

2)

( ) ( )Tn

S t t n T

[ ] ( ) ( ) ( ) ( ) ( ) ( )Tn n

x n x t S t x t t n T x n T t n T

Impulse train function

Page 7: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

7

C. Nikou – Digital Image Processing (E12)

1D continuous signals (cont.)Im

ag

es

take

n f

rom

Go

nza

lez

& W

oo

ds,

Dig

ital I

ma

ge

Pro

cess

ing

(2

00

2)

[ ] ( ) ( )Tx n x t S t

( ) ( )n

x t t n T

( ) ( )n

x n T t n T

Page 8: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

8

C. Nikou – Digital Image Processing (E12)

1D continuous signals (cont.)Im

ag

es

take

n f

rom

Go

nza

lez

& W

oo

ds,

Dig

ital I

ma

ge

Pro

cess

ing

(2

00

2) • The Fourier series expansion of a periodic

signal f (t).

2

( )j nt

Tn

n

f t c e

/ 2 2

/ 2

1( )

Tj nt

Tn

T

c f t e dtT

Page 9: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

9

C. Nikou – Digital Image Processing (E12)

1D continuous signals (cont.)Im

ag

es

take

n f

rom

Go

nza

lez

& W

oo

ds,

Dig

ital I

ma

ge

Pro

cess

ing

(2

00

2) • The Fourier transform of a continuous

signal f (t).

2( ) ( ) j tF f t e dt

2( ) ( ) j tf t F e d

• Attention: the variable is the frequency (Hz) and

not the radial frequency (Ω=2πμ) as in the Signals and Systems course.

Page 10: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

10

C. Nikou – Digital Image Processing (E12)

1D continuous signals (cont.)Im

ag

es

take

n f

rom

Go

nza

lez

& W

oo

ds,

Dig

ital I

ma

ge

Pro

cess

ing

(2

00

2)

/ 2

sin( )( ) ( ) ( )

( )W

Wf t P t F W

W

Page 11: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

11

C. Nikou – Digital Image Processing (E12)

1D continuous signals (cont.)Im

ag

es

take

n f

rom

Go

nza

lez

& W

oo

ds,

Dig

ital I

ma

ge

Pro

cess

ing

(2

00

2) • Convolution property of the FT.

( )* ( ) ( ) ( )

( )* ( ) ( ) ( )

f t h t f h t d

f t h t F H

( ) ( ) ( )* ( )f t h t F H

Page 12: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

12

C. Nikou – Digital Image Processing (E12)

1D continuous signals (cont.)Im

ag

es

take

n f

rom

Go

nza

lez

& W

oo

ds,

Dig

ital I

ma

ge

Pro

cess

ing

(2

00

2) • Intermediate result

− The Fourier transform of the impulse train.

1( )

n n

nt n T

T T

• It is also an impulse train in the frequency domain.

• Impulses are equally spaced every 1/ΔΤ.

Page 13: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

13

C. Nikou – Digital Image Processing (E12)

1D continuous signals (cont.)Im

ag

es

take

n f

rom

Go

nza

lez

& W

oo

ds,

Dig

ital I

ma

ge

Pro

cess

ing

(2

00

2)

[ ] ( ) ( )Tx n x t S t

( ) ( )n

x t t n T

( ) ( )n

x n T t n T

Sampling

Page 14: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

14

C. Nikou – Digital Image Processing (E12)

1D continuous signals (cont.)Im

ag

es

take

n f

rom

Go

nza

lez

& W

oo

ds,

Dig

ital I

ma

ge

Pro

cess

ing

(2

00

2) • Sampling

− The spectrum of the discrete signal consists of repetitions of the spectrum of the continuous signal every 1/ΔΤ.

− The Nyquist criterion should be satisfied.

( ) ( )

1( ) [ ] ( )

n

f t F

nf n T f n F F

T T

Page 15: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

15

C. Nikou – Digital Image Processing (E12)

1D continuous signals (cont.)Im

ag

es

take

n f

rom

Go

nza

lez

& W

oo

ds,

Dig

ital I

ma

ge

Pro

cess

ing

(2

00

2)

Nyquist theorem

max

12

T

Page 16: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

16

C. Nikou – Digital Image Processing (E12)

1D continuous signals (cont.)Im

ag

es

take

n f

rom

Go

nza

lez

& W

oo

ds,

Dig

ital I

ma

ge

Pro

cess

ing

(2

00

2)

Oversampling

Undersampling Aliasing appears

Critical sampling with the Nyquist frequency

FT of a continuous signal

Page 17: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

17

C. Nikou – Digital Image Processing (E12)

1D continuous signals (cont.)Im

ag

es

take

n f

rom

Go

nza

lez

& W

oo

ds,

Dig

ital I

ma

ge

Pro

cess

ing

(2

00

2) • Reconstruction (under correct sampling).

( ) ( ) ( )F F H

( ) ( )* sint

f t f t T cT

Page 18: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

18

C. Nikou – Digital Image Processing (E12)

1D continuous signals (cont.)Im

ag

es

take

n f

rom

Go

nza

lez

& W

oo

ds,

Dig

ital I

ma

ge

Pro

cess

ing

(2

00

2) • Reconstruction

− Provided a correct sampling, the continuous signal may be perfectly reconstructed by its samples.

( )( ) ( ) sinc

n

t n Tf t f n T

n T

Page 19: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

19

C. Nikou – Digital Image Processing (E12)

1D continuous signals (cont.)Im

ag

es

take

n f

rom

Go

nza

lez

& W

oo

ds,

Dig

ital I

ma

ge

Pro

cess

ing

(2

00

2)

• Under aliasing, the reconstruction of the continuous signal not correct.

Page 20: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

20

C. Nikou – Digital Image Processing (E12)

1D continuous signals (cont.)Im

ag

es

take

n f

rom

Go

nza

lez

& W

oo

ds,

Dig

ital I

ma

ge

Pro

cess

ing

(2

00

2)

Aliased signal

Page 21: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

21

C. Nikou – Digital Image Processing (E12)

The Discrete Fourier TransformIm

ag

es

take

n f

rom

Go

nza

lez

& W

oo

ds,

Dig

ital I

ma

ge

Pro

cess

ing

(2

00

2) • The Fourier transform of a sampled (discrete)

signal is a continuous function of the frequency.

1( )

n

nF F

T T

• For a N-length discrete signal, taking N samples of its Fourier transform at frequencies:

provides the discrete Fourier transform (DFT) of the signal.

0,1, .., 1,k k Nk

N T

Page 22: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

22

C. Nikou – Digital Image Processing (E12)

The Discrete Fourier Transform (cont.)

Ima

ge

s ta

ken

fro

m G

on

zale

z &

Wo

od

s, D

igita

l Im

ag

e P

roce

ssin

g (

20

02

) • DFT pair of signal f [n] of length N.

21

0

21

0

0 1

0 1

[ ] [ ] ,

1[ ] [ ] ,

nkN jN

n

nkN jN

n

k N

n N

F k f n e

f n F k eN

Page 23: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

23

C. Nikou – Digital Image Processing (E12)

The Discrete Fourier Transform (cont.)

Ima

ge

s ta

ken

fro

m G

on

zale

z &

Wo

od

s, D

igita

l Im

ag

e P

roce

ssin

g (

20

02

) • Property– The DFT of a N-length f [n] signal is periodic

with period N.

[ ] [ ]F k N F k

– This is due to the periodicity of the complex exponential:

2 2n n

j jn nN NN Nw e w e

Page 24: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

24

C. Nikou – Digital Image Processing (E12)

The Discrete Fourier Transform (cont.)

Ima

ge

s ta

ken

fro

m G

on

zale

z &

Wo

od

s, D

igita

l Im

ag

e P

roce

ssin

g (

20

02

) • Property: sum of complex exponentials

0

1, ,1

0, otherwise

NknN

n

k rN rw

N

The proof is left as an exercise.

2j

NNw e

Page 25: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

25

C. Nikou – Digital Image Processing (E12)

The Discrete Fourier Transform (cont.)

Ima

ge

s ta

ken

fro

m G

on

zale

z &

Wo

od

s, D

igita

l Im

ag

e P

roce

ssin

g (

20

02

) • DFT pair of signal f [n] of length N may be expressed in matrix-vector form.

1

0

1

0

0 1

0 1

[ ] [ ] ,

1[ ] [ ] ,

NnkN

n

Nnk

Nn

k N

n N

F k f n w

f n F k wN

2

jN

Nw e

Page 26: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

26

C. Nikou – Digital Image Processing (E12)

The Discrete Fourier Transform (cont.)

F = Af

[0], [1],..., [ 1] , [0], [1],..., [ 1]T T

f f f N F F F N f = F =

0 1 2 10 0 0 0

0 1 2 11 1 1 1

0 1 2 11 1 1 1

N

N N N N

N

N N N N

NN N N NN N N N

w w w w

w w w w

w w w w

A

Page 27: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

27

C. Nikou – Digital Image Processing (E12)

The Discrete Fourier Transform (cont.)

Example for N=4

1 1 1 1

1 1

1 1 1 1

1 1

j j

j j

A

Page 28: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

28

C. Nikou – Digital Image Processing (E12)

The Discrete Fourier Transform (cont.)

The inverse DFT is then expressed by:-1f = A F

*0 1 2 10 0 0 0

0 1 2 11 1 1 11 *

0 1 2 11 1 1 1

1 1

TN

N N N N

NT

N N N N

NN N N NN N N N

w w w w

w w w w

N N

w w w w

A A

This is derived by the complex exponential sum property.

Page 29: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

29

C. Nikou – Digital Image Processing (E12)

Linear convolution

is of length N=N1+N2-1=4

1 2[ ] {1, 2, 2}, [ ] {1, 1}, 3, 2f n h n N N

[ ] [ ]* [ ] [ ] [ ]m

g n f n h n f m h n m

Page 30: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

30

C. Nikou – Digital Image Processing (E12)

Linear convolution (cont.)

1 2[ ] {1, 2, 2}, [ ] {1, 1}, 3, 2f n h n N N

[ ] 1 2 2 [ ]

0 [0 ] 1 1 1

1 [1 ] 1 1 1

2 [2 ] 1 1 0

3 [3 ] 1 1 2

f m g n

n h m

n h m

n h m

n h m

[ ] [ ]* [ ] [ ] [ ]m

g n f n h n f m h n m

[ ] {1, 1, 0, 2}g n

Page 31: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

31

C. Nikou – Digital Image Processing (E12)

Circular shift

• Signal x[n] of length N.

• A circular shift ensures that the resulting signal will keep its length N.

• It is a shift modulo N denoted by

[( ) ] [( ) mod ]Nx n m x n m N

• Example: x[n] is of length N=8.

8[( 2) ] [( 2) ] [6]Nx x x

8[(10) ] [(10) ] [2]Nx x x

Page 32: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

32

C. Nikou – Digital Image Processing (E12)

Circular convolution

The result is of length

1 2[ ] {1, 2, 2}, [ ] {1, 1}, 3, 2f n h n N N

[ ] [( ) ]Nm

f m h n m

g[n]=f [n]h[n]

1 2max , 3N N N

Circular shift modulo N

Page 33: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

33

C. Nikou – Digital Image Processing (E12)

Circular convolution (cont.)

1 2[ ] {1, 2, 2}, [ ] {1, 1}, 3, 2f n h n N N

[ ] 1 2 2 [ ]

0 [(0 ) ] 1 1 1 1

1 [(1 ) ] 1 1 1

2 [(2 ) ] 1 1 0

N

N

N

f m g n

n h m

n h m

n h m

[ ] { 1, 1, 0,}g n

[ ] [( ) ]Nm

f m h n m

g[n]=f [n]h[n]

Page 34: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

34

C. Nikou – Digital Image Processing (E12)

DFT and convolution

[ ] [ ] [ ]G k F k H k g[n]=f [n]h[n]

• The property holds for the circular convolution.

• In signal processing we are interested in linear convolution.

• Is there a similar property for the linear convolution?

Page 35: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

35

C. Nikou – Digital Image Processing (E12)

DFT and convolution (cont.)

[ ] [ ] [ ]G k F k H k g[n]=f [n]h[n]

• Let f [n] be of length N1 and h[n] be of length N2.

• Then g[n]=f [n]*h[n] is of length N1+N2-1.

• If the signals are zero-padded to length N=N1+N2-1 then their circular convolution will be the same as their linear convolution:

[ ] [ ]* [ ] [ ] [ ] [ ]g n f n h n G k F k H k

Zero-padded signals

Page 36: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

36

C. Nikou – Digital Image Processing (E12)

DFT and convolution (cont.)

1 2[ ] {1, 2, 2}, [ ] {1, 1}, 3, 2f n h n N N

[ ] {1, 2, 2, 0}, [ ] {1, 1, 0, 0}f n h n Zero-padding to length N=N1+N2-1 =4

4

4

4

4

[ ] 1 2 2 0 [ ]

[( 0) ] 0 0 1 1 0 0 1 1

[( 1) ] 0 0 1 1 0 0 1

[( 2) ] 0 0 1 1 0 0

[( 3) ] 0 0 1 1 2

f m g n

h n

h n

h n

h n

The result is the same as the linear convolution.

Page 37: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

37

C. Nikou – Digital Image Processing (E12)

DFT and convolution (cont.)

Verification using DFT1 1 1 1 1 5

1 1 2 1 2

1 1 1 1 2 1

1 1 0 1 2

j j j

j j j

F = Af

1 1 1 1 1 0

1 1 1 1

1 1 1 1 0 2

1 1 0 1

j j j

j j j

H = Ah

Page 38: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

38

C. Nikou – Digital Image Processing (E12)

DFT and convolution (cont.)

Element-wise multiplication

[ ] [ ] [ ]G k F k H k

5 0 0

( 1 2) (1 ) 1 3

1 2 2

( 1 2) (1 ) 1 3

j j j

j j j

G = F H

Page 39: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

39

C. Nikou – Digital Image Processing (E12)

DFT and convolution (cont.)

Inverse DFT of the result

1 *

1 1 1 1 0 1

1 1 1 3 11

1 1 1 1 2 04

1 1 1 3 2

T j j j

j j j

g = A G = A

The same result as their linear convolution.

Page 40: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

40

C. Nikou – Digital Image Processing (E12)

2D continuous signalsIm

ag

es

take

n f

rom

Go

nza

lez

& W

oo

ds,

Dig

ital I

ma

ge

Pro

cess

ing

(2

00

2)

0 0 0 0( , ) ( ) ( )x x y y x x y y Separable:

0 0 0 0( , ) ( , ) ( , )f x y x x y y dydx f x y

0 00 0

, ,( , )

0 otherwise

x x y yx x y y

Page 41: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

41

C. Nikou – Digital Image Processing (E12)

2D continuous signals (cont.)Im

ag

es

take

n f

rom

Go

nza

lez

& W

oo

ds,

Dig

ital I

ma

ge

Pro

cess

ing

(2

00

2)

The 2D impulse train is also separable:

( , ) ( ) ( ) ( , )X Y X Yn m

S x y S x S y x n X y n Y

Page 42: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

42

C. Nikou – Digital Image Processing (E12)

2D continuous signals (cont.)Im

ag

es

take

n f

rom

Go

nza

lez

& W

oo

ds,

Dig

ital I

ma

ge

Pro

cess

ing

(2

00

2) • The Fourier transform of a continuous 2D

signal f (x,y).

2 ( )( , ) ( , ) j x vyF f x y e dydx

2 ( )( , ) ( , ) j x vyf x y F e d d

Page 43: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

43

C. Nikou – Digital Image Processing (E12)

2D continuous signals (cont.)Im

ag

es

take

n f

rom

Go

nza

lez

& W

oo

ds,

Dig

ital I

ma

ge

Pro

cess

ing

(2

00

2) • Example: FT of f (x,y)=δ(x)

2 ( )( , ) ( ) j x vyF x e dydx

2 2( ) j x j vyx e dx e dy

2j vye dy

( )

x

y f (x,y)=δ(x)

μ

ν F(μ,ν)=δ(ν)

Page 44: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

44

C. Nikou – Digital Image Processing (E12)

2D continuous signals (cont.)Im

ag

es

take

n f

rom

Go

nza

lez

& W

oo

ds,

Dig

ital I

ma

ge

Pro

cess

ing

(2

00

2) • Example: FT of f (x,y)=δ(x-y)

2 ( )( , ) ( ) j x vyF x y e dydx

2 2( ) j x j vyx y e dx e dy

2 2j y j ye e dy

( )

x

yf (x,y)=δ(x-y)

μ

ν F(μ,ν)=δ(μ+ν)

2 ( )j ye dy

Page 45: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

45

C. Nikou – Digital Image Processing (E12)

2D continuous signals (cont.)Im

ag

es

take

n f

rom

Go

nza

lez

& W

oo

ds,

Dig

ital I

ma

ge

Pro

cess

ing

(2

00

2)

2/ 2, / 2

sin( ) sin( )( , ) ( , ) ( , )

( ) ( )W W

W Wf x y P x y F W

W W

Page 46: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

46

C. Nikou – Digital Image Processing (E12)

2D continuous signals (cont.)Im

ag

es

take

n f

rom

Go

nza

lez

& W

oo

ds,

Dig

ital I

ma

ge

Pro

cess

ing

(2

00

2) • 2D continuous convolution

( , )* ( , ) ( , ) ( , )f x y h x y F H

( , )* ( , ) ( , ) ( , )f x y h x y f x y h d d

• We will examine the discrete convolution in more detail.

• Convolution property

Page 47: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

47

C. Nikou – Digital Image Processing (E12)

2D continuous signals (cont.)Im

ag

es

take

n f

rom

Go

nza

lez

& W

oo

ds,

Dig

ital I

ma

ge

Pro

cess

ing

(2

00

2) • 2D sampling is accomplished by

( , ) ( , )X Yn m

S x y x n X y n Y

• The FT of the sampled 2D signal consists of repetitions of the spectrum of the 1D continuous signal.

1 1( , ) ,

n

m nF F

X Y X Y

Page 48: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

48

C. Nikou – Digital Image Processing (E12)

2D continuous signals (cont.)Im

ag

es

take

n f

rom

Go

nza

lez

& W

oo

ds,

Dig

ital I

ma

ge

Pro

cess

ing

(2

00

2) • The Nyquist theorem involves both the

horizontal and vertical frequencies.

max max

1 12 , 2v

X Y

Over-sampled Under-sampled

Page 49: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

49

C. Nikou – Digital Image Processing (E12)

AliasingIm

ag

es

take

n f

rom

Go

nza

lez

& W

oo

ds,

Dig

ital I

ma

ge

Pro

cess

ing

(2

00

2)

Page 50: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

50

C. Nikou – Digital Image Processing (E12)

Aliasing - Moiré Patterns

• Effect of sampling a scene with periodic or nearly periodic components (e.g. overlapping grids, TV raster lines and stripped materials).

• In image processing the problem arises when scanning media prints (e.g. magazines, newspapers).

• The problem is more general than sampling artifacts.

Page 51: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

51

C. Nikou – Digital Image Processing (E12)

Aliasing - Moiré Patterns (cont.)

• Superimposed grid drawings (not digitized) produce the effect of new frequencies not existing in the original components.

Page 52: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

52

C. Nikou – Digital Image Processing (E12)

Aliasing - Moiré Patterns (cont.)

• In printing industry the problem comes when scanning photographs from the superposition of:

• The sampling lattice (usually horizontal and vertical).

• Dot patterns on the newspaper image.

Page 53: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

53

C. Nikou – Digital Image Processing (E12)

Aliasing - Moiré Patterns (cont.)

Page 54: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

54

C. Nikou – Digital Image Processing (E12)

Aliasing - Moiré Patterns (cont.)

• The printing industry uses halftoning to cope with the problem.

• The dot size is inversely proportional to image intensity.

Page 55: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

55

C. Nikou – Digital Image Processing (E12)

2D discrete convolutionIm

ag

es

take

n f

rom

Go

nza

lez

& W

oo

ds,

Dig

ital I

ma

ge

Pro

cess

ing

(2

00

2)

m

n3 2

f [m,n] m

n

1 11 -1

h [m,n]

[ , ] [ , ]* [ , ] [ , ] [ , ]k l

g m n f m n h m n f k l h m k n l

• Take the symmetric of one of the signals with respect to the origin.

• Shift it and compute the sum at every position [m,n].

Page 56: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

56

C. Nikou – Digital Image Processing (E12)

2D discrete convolution (cont.)Im

ag

es

take

n f

rom

Go

nza

lez

& W

oo

ds,

Dig

ital I

ma

ge

Pro

cess

ing

(2

00

2)

n

m3 2

f [m,n] n

m

1 11 -1

h [m,n]

l

k

h [1-k,1-l]

-1 11 1

3 2

l

k

h [-k,-l]

-1 11 1

3 2

g [0,0]=0 g [1,1]=0

Page 57: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

57

C. Nikou – Digital Image Processing (E12)

2D discrete convolution (cont.)Im

ag

es

take

n f

rom

Go

nza

lez

& W

oo

ds,

Dig

ital I

ma

ge

Pro

cess

ing

(2

00

2)

n

m3 2

f [m,n] n

m

1 11 -1

h [m,n]

l

k

h [3-k,2-l]-1 11 13 2

l

k

h [2-k,2-l]-1 11 1

3 2

g [2,2]=3 g [3,2]=-1

Page 58: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

58

C. Nikou – Digital Image Processing (E12)

2D discrete convolution (cont.)Im

ag

es

take

n f

rom

Go

nza

lez

& W

oo

ds,

Dig

ital I

ma

ge

Pro

cess

ing

(2

00

2)

n

m3 2

f [m,n] n

m

1 11 -1

h [m,n]

n

m

g[m,n]3 53 -1

2-3

M1+M2-1=3N1+N2-1=2

Page 59: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

59

C. Nikou – Digital Image Processing (E12)

The 2D DFTIm

ag

es

take

n f

rom

Go

nza

lez

& W

oo

ds,

Dig

ital I

ma

ge

Pro

cess

ing

(2

00

2) • 2D DFT pair of image f [m,n] of size MxN.

1 1 2

0 0

1 1 2

0 0

[ , ] [ , ]

1[ , ] [ , ]

km lnM N jM N

m n

km lnM N jM N

m n

F k l f m n e

f m n F k l eMN

0 1 0 1

0 1 0 1,

k M m M

l N n N

Page 60: University of Ioannina - Department of Computer Science Filtering in the Frequency Domain (Fundamentals) Digital Image Processing Christophoros Nikou cnikou@cs.uoi.gr.

60

C. Nikou – Digital Image Processing (E12)

The 2D DFT (cont.)Im

ag

es

take

n f

rom

Go

nza

lez

& W

oo

ds,

Dig

ital I

ma

ge

Pro

cess

ing

(2

00

2) • All of the properties of 1D DFT hold.

• Particularly:– Let f [m,n] be of size M1xN1 and h[m,n] of size

M2xN2 .

– If the signals are zero-padded to size (M1+M2-1)x(N1+N2-1) then their circular convolution will be the same as their linear convolution and:

[ , ] [ , ]* [ , ] [ , ] [ , ] [ , ]g m n f m n h m n G k l F k l H k l