0% found this document useful (0 votes)
5 views

DIP Chapter 4 Filtering in the Frequency Domain M2

Uploaded by

prisha1529
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

DIP Chapter 4 Filtering in the Frequency Domain M2

Uploaded by

prisha1529
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 45

Digital Image Processing, 3rd ed.

Gonzalez & Woods


www.ImageProcessingPlace.com

Chapter 4
Filtering in the Frequency Domain

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 4
Filtering in the Frequency Domain

Extension to 2D
��
δ(tt0−, zt0 ,−
z−
∞∞ for tt ==t0t,0z, z==
z0 z0
δ(t − z0z)0=
)=

00 otherwise
otherwise
∞ for t = t0 , z = z0
� ∞ � ∞ δ(t − t0 , z − z0 ) =
δ(t − t0 , z − z0 )dtdz = 1
0 otherwise
−∞ −∞
� ∞ � ∞
� ∞ � ∞ δ(t − t0 , z − z0 )dtdz = 1
−∞ −∞
f (t, z)δ(t − t0 , z − z0 )dtdz = f (t0 , z0 )
−∞ −∞
Sifting: � ∞ � ∞
f (t, z)δ(t − t0 , z − z0 )dtdz = f (t0 , z0 )
−∞ −∞

© 1992–2008 R. C. Gonzalez & R. E. Woods


� ∞ � ∞ Digital Image Processing, 3rd ed.
� ∞ � ∞ δ(t − t0 , z − Gonzalez
z0 )dtdz =1
& Woods
−∞ −∞ δ(t − t0 , z − z0 )dtdz = 1
www.ImageProcessingPlace.com
−∞ −∞
� ∞ � ∞ Chapter 4

� ∞ � ∞ Filtering in the Frequency Domain


f (t, z)δ(t − t0 , z − z0 )dtdz = f (t0 , z0 )
−∞ −∞ f (t, z)δ(t − t0 , z − z0 )dtdz = f (t0 , z0 )
−∞ −∞ � ∞ � ∞
F (µ, ν) = � ∞ � ∞ f (t, z)e−j2π(µt+νz)
−j2π(µt+νz)
dtdz Fourier transform
F (µ, ν) = −∞ −∞ f (t, z)e dtdz
� −∞
∞ � −∞

f (x, y) = � ∞ � ∞ −j2π(µt+νz)
F (µ, ν)e j2π(µt+νz) dµdν
f (x, y) = −∞ −∞ F (µ, ν)e dµdν
−∞ −∞ Inverse Fourier
F (µ, ν) = AT Z sinc(µT ) sinc(νZ) transform

� ∞

s∆T ∆Z (t, z) = δ(t − m∆T, z − n∆Z)
m=−∞ n=−∞

1 1
∆T < , ∆Z <
2µmax 2νmax
nsforms:
M
� −1 N

© 1992–2008 R. C. Gonzalez & R. E. Woods
−1
δ(t − t0 ,Digital
z − z0Image
)dtdzProcessing,
=1 3rd ed.
−∞ −∞
Gonzalez & Woods
www.ImageProcessingPlace.com
� ∞ � ∞
f (t, z)δ(t − t0 , z − z0 )dtdzChapter
= f (t4
0 , z0 )
−∞ −∞ Filtering in the Frequency Domain
� ∞ � ∞
−j2π(µt+νz)
F (µ,
Forν)the f (t,
= rectangular z)e the transform
impulse, dtdz is a tensor product of two
−∞ −∞
sinc functions
� ∞ � ∞
f (x, y) = F (µ, ν)e−j2π(µt+νz) dµdν
−∞ −∞

F (µ, ν) = AT Z sinc(µT ) sinc(νZ)

© 1992–2008 R. C. Gonzalez & R. E. Woods


� ∞ � ∞
Digital Image Processing, 3rd ed.
δ(t − t0 , zGonzalez
− z0&)dtdz
Woods
=1
−∞ −∞
www.ImageProcessingPlace.com

� ∞ � ∞ Chapter 4
Filtering in the Frequency Domain
f (t, z)δ(t − t0 , z − z0 )dtdz = f (t0 , z0 )
−∞ −∞
� ∞ � ∞
−j2π(µt+νz)
DiracFcomb = spike mat f (t, z)e
(µ, ν)->
−∞ −∞
dtdz
� ∞ � ∞
f (x, y) = F (µ, ν)e−j2π(µt+νz) dµdν
−∞ −∞

F (µ, ν) = AT Z sinc(µT ) sinc(νZ)



� ∞

s∆T ∆Z (t, z) = δ(t − m∆T, z − n∆Z)
m=−∞ n=−∞

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital δ(t − Processing,
Image t0 , z − z03rd
)dtdz
ed. =1
−∞ −∞
Gonzalez & Woods
fting: � ∞ � ∞
www.ImageProcessingPlace.com

Chapter 4
(t, z)δ(tin −
fFiltering t0 , z − z0 )dtdz
the Frequency Domain
= f (t0 , z0 )
−∞ −∞
� ∞ � ∞
F (µ, ν) = f (t, z)e−j2π(µt+νz) dtdz
We say that f(t,z) is band−∞
limited
−∞ if the transform F(µ,v) =0 outside
� ∞ � ∞
the rectangle [-µmax, µmax] and [-vmax, v−j2π(µt+νz)
max]
f (x, y) = F (µ, ν)e dµdν
−∞ −∞

F (µ, ν) = AT Z sinc(µT ) sinc(νZ)


2D Sampling Theorem:� A
∞ continuous,

� band-limited 2D function
s∆T ∆Z (t,without
can be recovered z) = error if theδ(t − m∆T,intervals
sampling z − n∆Z)
are
m=−∞ n=−∞

1 1
∆T < , ∆Z <
2µmax 2νmax

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 4
Filtering in the Frequency Domain

Aliasing for images

The effect of aliasing in images gives artifacts like spurious highlights


and patterns that are not present in the original image.

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 4
Filtering in the Frequency Domain

Often these patterns appear when downsampling an image (f.ex. by


interpolation).
© 1992–2008 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 4
Filtering in the Frequency Domain

Zooming <=> oversampling


Shrinking <=> undersampling

The effect of aliasing can be attenuated


by a slight defocusing (blurring), prior
to the downsampling.

Such defocusing attenuates the high


frequencies before the sampling.

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 4
Filtering in the Frequency Domain

jaggies: stair-stepped effects in an


image on diagonal lines or curves

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 4
Filtering in the Frequency Domain

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 4
Filtering in the Frequency Domain

Another well known artifact: moiré (pron. morei) patterns

These are produced as “interference” patterns of two patterns with


approximately the same spacing.

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 4
Filtering in the Frequency Domain

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 4
Filtering in the Frequency Domain

© 1992–2008 R. C. Gonzalez & R. E. Woods


F (µ, ν)
−∞= −∞ AT Z sinc(µT
Digital Image Processing, 3rd ed.
) sinc(νZ)
F (µ, ν) =�
Gonzalez AT Z�
∞Woods
& sinc(µT
∞ ) sinc(νZ)
s∆T ∆Z (t, z) = � ∞ � ∞ δ(t − m∆T, z − n∆Z)
www.ImageProcessingPlace.com

m=−∞
s∆T ∆Z (t, z) = Chapter 4 n=−∞ δ(t − m∆T, z − n∆Z)
Filtering in the Frequency
m=−∞ 1 n=−∞Domain 1
∆T < , ∆Z <
2µ1 max 1 max

∆T < , ∆Z <
Discrete transforms: 2µmax 2νmax
Discrete transforms: M −1 N −1
� �
−j2π(ux/M +vy/N )
F (u, v) =M� −1 N �−1 f (x, y)e
−j2π(ux/M +vy/N )
F (u, v) = x=0 y=0f (x, y)e
x=0 y=0
Inverse discrete transform:
Inverse discrete transform: M −1 N −1
1 � �
−j2π(ux/M +vy/N )
f (x, y) = 1 M� −1 N
� −1 F (u, v)e
f (x, y) = M N u=0 v=0F (u, v)ej2π(ux/M +vy/N )
M N u=0 v=0

f (x − x0 , y − y0 ) ⇔ F (u, v)e−j2π(x0 u/M +y0 v/N )

© 1992–2008 R. C. Gonzalez & R. E. Woods


F (u − u0 , v − v0 ) ⇔ f (x, y)ej2π(xu0 /M +yv0 /N )
Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 4
F (uFiltering
+ k1 M, v +Frequency
in the k2 N ) =Domain
F (u, v)
f (x + k1 M, y + k2 N ) = f (x, y)
Note that jφ(u,v)
F (u, v) = |F (u, v)|e
M
� −1 N
� −1
F (0, 0) = f (x, y) = M N f¯(x, y)
x=0 y=0

is the average of the image values multiplied by the size of the


image.

This value can be much larger than the other components

© 1992–2008 R. C. Gonzalez & R. E. Woods


M
� −1 N
Digital� −1 Processing, 3rd ed.
Image
−1 N −1 f (x, y)e −j2π(ux/M +vy/N )
F (u, v) = M� � Gonzalez & Woods
F (u, v) = x=0 y=0 f (x, y)e−j2π(ux/M +vy/N )
www.ImageProcessingPlace.com

x=0 y=0
Chapter 4
rse discrete transform: Filtering in the Frequency Domain
rse discrete transform:
M
� −1 N�−1
1 M −j2π(ux/M +vy/N )
Translation and=Rotation
f (x, y) 1 � properties:
−1 N
� −1 F (u, v)e−j2π(ux/M +vy/N )
f (x, y) = M N u=0 v=0 F (u, v)e
M N u=0 v=0
−j2π(x0 u/M +y0 v/N )
f (x − x0 , y − y0 ) ⇔ F (u, v)e−j2π(x 0 u/M +y0 v/N )
f (x − x0 , y − y0 ) ⇔ F (u, v)e j2π(xu /M +yv /N )
F (u − u0 , v − v0 ) ⇔ f (x, y)ej2π(xu00/M +yv00/N )
F (u − u0 , v − v0 ) ⇔ f (x, y)e

1
1
Moreover, rotating f corresponds to rotating F of the same angle (and
vice-versa)

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital
M
� −1Image
N
� −1Processing, 3rd ed.
−j2π(ux/M +vy/N )
F (u, v) = f (x, y)e
Gonzalez & Woods
www.ImageProcessingPlace.com
x=0 y=0
Chapter 4
nverse discrete transform:
Filtering in the Frequency Domain
M
� −1 N
� −1
1
f (x,
Periodicity: y) = F (u, v)e−j2π(ux/M +vy/N )
MN u=0 v=0
−j2π(x0 u/M +y0 v/N )
for any integers
f (x − xk01,and
y − ky2:0 ) ⇔ F (u, v)e
j2π(xu0 /M +yv0 /N )
F (u − u0 , v − v0 ) ⇔ f (x, y)e
F (u + k1 M, v + k2 N ) = F (u, v)
f (x + k1 M, y + k2 N ) = f (x, y)

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 4
Filtering in the Frequency Domain

working with fft in matlab:


puls = rectpuls(-1:.1:1, .5);

figure, plot(real(fft(puls)))

high frequencies

Low frequencies
© 1992–2008 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 4
Filtering in the Frequency Domain

rectangular impulse <-> sinc function


To see the sinc function, we have to wrap around in order to move the
low frequencies to the middle of the interval

fftshift

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 4
Filtering in the Frequency Domain

rectangular impulse <-> sinc function


To see the sinc function, we have to wrap around in order to move the
low frequencies to the middle of the interval

fftshift

>> figure, plot(fftshift(real(fft


(puls))),…
'LineWidth', 4)

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 4
Filtering in the Frequency Domain

The same happens in 2 dimension:

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 4
Filtering in the Frequency Domain

The same happens in 2 dimension:


fft2

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 4
Filtering in the Frequency Domain

The same happens in 2 dimension:


fft2 fftshift

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 4
Filtering in the Frequency Domain

The same happens in 2 dimension:


fft2 fftshift

The same effect can be achieved by


f(x,y) -> f(x,y) (-1)^(x+y)

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 4
Filtering in the Frequency Domain

The same happens in 2 dimension:


fft2 fftshift

The same effect can be achieved by


f(x,y) -> f(x,y) (-1)^(x+y)

Here we have applied a power tranformation


to highlight the details.

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 4
Filtering in the Frequency Domain

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 4
Filtering in the Frequency Domain

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 4
Filtering in the Frequency Domain

© 1992–2008 R. C. Gonzalez & R. E. Woods


1 −j2π(ux/M +vy/N )
f (x, y) = Digital Image F (u, v)e 3rd ed.
Processing,
M N u=0 v=0Gonzalez & Woods
www.ImageProcessingPlace.com
−j2π(x0 u/M +y0 v/N )
f (x − x0 , y − y0 ) ⇔ F (u, v)e
Chapter 4
F (u − u0 , v Filtering
− v0 ) ⇔ f (x,
in the y)ej2π(xu
Frequency 0 /M +yv0 /N )
Domain

F (u + k1 M, v + k2 N ) = F (u, v)
Spectrum and phase angle:
f (x + k1 M, y + k2 N ) = f (x, y)
jφ(u,v)
F (u, v) = |F (u, v)|e

Spectrum
1 phase angle

Power spectrum = spectrum^2

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 4
Filtering in the Frequency Domain

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 4
Filtering in the Frequency Domain

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 4
Filtering in the Frequency Domain

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 4
Filtering in the Frequency Domain

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 4
Filtering in the Frequency Domain

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 4
Filtering in the Frequency Domain

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com
F (u + k1 M, v + k2 N ) = F (u, v)
Chapter 4
f (x + kin1 M,
Filtering theyFrequency
+ k2 N ) = f (x, y)
Domain

F (u, v) = |F (u, v)|ejφ(u,v)


FilteringM�
in Nthe
−1 �−1 frequency domain
F (0, 0) = f (x, y) = M N f¯(x, y)
x=0 y=0

g(x, y) = F −1 [H(u, v)F (u, v)]

Filter function

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 4
Filtering in the Frequency Domain

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 4
Filtering in the Frequency Domain

Lowpass filters:

Highpass filters:

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 4
Filtering in the Frequency Domain

Lowpass filters: These are filters that allow only the low
frequencies and take out the high frequencies

Highpass filters: These are filters that allow only the high
frequencies and take out the low frequencies

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 4
Filtering in the Frequency Domain

Lowpass filters: These are filters that allow only the low
frequencies and take out the high frequencies

low frequencies: smoothing

Highpass filters: These are filters that allow only the high
frequencies and take out the low frequencies

high frequencies: sharpening

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 4
Filtering in the Frequency Domain

We consider real filters H(u,v)

G(x,y) = H(u,v) (R(u,v) + j I(u,v))


= H(u,v) R(u,v) + j H(u,v) I(u,v)

The phase angle, arctan(H(u,v)I(u,v) / H(u,v) F(u,v)) is unchanged!

(zero phase shift).

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 4
Filtering in the Frequency Domain

Main steps of filtering in the frequency domain:

Assume f(x,y) (image), h(x,y) (filter), in the spatial domain given:


1. Pad f(x,y) to obtain fp(x,y), and similarly for h, hp
2. Compute dft of fp, hp (matlab: fft2)
3. Center the transforms (matlab: fftshift), Fp, Hp
4. Multiply G(x,y) = Fp(x,y) Hp(x,y)

5. Obtain the processed image gp(x,y) = Real(ifft2(fftshift(G(u,v)))


(extract the desired subportion).

NB. We take the real part to remove spurious imaginary parts that
come from our computations (rounding etc.)
© 1992–2008 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 4
Filtering in the Frequency Domain

Lowpass filters:

- Ideal lowpass filter

- Gaussian lowpass filter

- Butterworth lowpass filter

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 4
Filtering in the Frequency Domain

F (u + k1 M, v + k2 N ) = F (u, v)
F (u + k1 M, v + k2 N ) = F (u, v)
f (x + k1 M, y + k2 N ) = f (x, y)
jφ(u,v) f (x + k1 M, y + k2 N ) = f (x, y)
F (u, v) = |F (u, v)|e
M −1 N −1 F (u, v) = |F (u, v)|ejφ(u,v)
� �
F (0, 0) = f (x, y) = M N f¯(x, y) M
� −1 N
� −1
x=0 y=0 F (0, 0) = f (x, y) = M N f¯(x, y
x=0 y=0
g(x, y) = F −1 [H(u, v)F (u, v)]
g(x, y) = F −1 [H(u, v)F (u, v)]
H(u, v) = 1, if D(u, v) ≤ D0
H(u, v) = 0 if D(u, v) > D0 H(u, v) = 1, if D(u
H(u, v) = 0 if D(u

D(u, v) = (u − P/2)2 + (v − Q/2)2

distance from the center of the image


© 1992–2008 R. C. Gonzalez & R. E. Woods

You might also like