43
Image Analysis and Processing Image Enhancements in the Frequency Domain Laurent Najman [email protected] ESIEE Paris Universit´ e Paris-Est, Laboratoire d’Informatique Gaspard-Monge, ´ Equipe A3SI image processing, transforms – p. 1/46

Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

  • Upload
    others

  • View
    32

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

Image Analysis and Processing

Image Enhancementsin the Frequency Domain

Laurent Najman

[email protected]

ESIEE Paris

Universite Paris-Est, Laboratoire d’Informatique Gaspard-Monge, Equipe

A3SI

image processing, transforms – p. 1/46

laurentnajman
Texte tapé à la machine
Page 2: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

Book

Chapter 4 (pages 147–219)

Digital Image Processing, Second Editionauthors: Rafael C. Gonzalez and Richard E. Woodseditor: Prentice Hall

– p.3/44

Page 3: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

Frequency Domain Filtering Operation

Frequency domain: space defined by values of the Fourier transform and itsfrequency variables (u, v).

Relation between Fourier Domain and image:

u = v = 0 corresponds to the gray-level average

Low frequencies: image’s component with smooth gray-level variation (e.g.areas with low variance)

High frequencies: quick gray-level change (e.g. edges, noise)

Source: http://www.imageprocessingbook.com – p.4/44

Page 4: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

Filtering in the Frequency Domain

Let H(u, v) a filter, also called filter transfer function.

Filter: suppress certain frequencies while leavingothers unchanged

G(u, v) = H(u, v)F (u, v)

H(u, v) in image processing:In general H(u, v) is real: zero-phase-shift filterH multiply real and imaginary parts of F

Φ(u, v) = tan−1 I(u,v)R(u,v) does not change if H is real

– p.5/44

Page 5: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

General Steps for Filtering

1. Multiply input image by (−1)x+y (centering)

2. Compute F (u, v) (DFT)

3. Multiply F (u, v) by H(u, v) (filtering)

4. Compute inverse DFT of H(u, v)F (u, v)

5. Obtain the real part of the result

6. Mutliply by (−1)x+y (decentering)

– p.6/44

Page 6: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

From Spatial to Frequency Domain

f(x, y) ∗ h(x, y) ⇔ F (u, v)H(u, v)

δ(x, y) ∗ h(x, y) ⇔ F [δ(u, v)]H(u, v)

h(x, y) ⇔ H(u, v)

Multiplication in the frequency domain is a convolutionin the spatial domain.

Given h(x, y), we can obtain H(u, v) by taking theinverse Fourier transform.

– p.7/44

Page 7: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

Padding (1)

convolution:

f(x) ∗ h(x) =1

M

M−1∑

m=0

f(m)h(x − m)

periodicity:

F (u, v) = F (u + M, v) = F (u, v + N) = F (u + M, v + N)

– p.8/44

Page 8: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

Padding (2)

Source: http://www.imageprocessingbook.com – p.9/44

Page 9: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

Padding (3)Let P an identical period for f and g:

fe(x) =

{

f(x) 0 ≤ x ≤ A − 1

0 A ≤ x ≤ P

ge(x) =

{

g(x) 0 ≤ x ≤ B − 1

0 B ≤ x ≤ P

If P < A + B − 1, the two signal will overlap:wraparound error.

If P > A + B − 1, the periods will be separated.

If P = A + B − 1, the periods will be adjacent.

We can avoid wraparound error using P ≥ A + B − 1.

In general, we use P = A + B − 1.– p.10/44

Page 10: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

Padding (4)

Source: http://www.imageprocessingbook.com – p.11/44

Page 11: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

Padding (5)

Source: http://www.imageprocessingbook.com – p.12/44

Page 12: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

Padding: Example

Source: http://www.imageprocessingbook.com – p.13/44

Page 13: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

Spatial Representation of a Filter

1. Multiply filter H(u, v) by (−1)u+v (centering)

2. Compute the inverse DFT

3. Multiply the real part of the inverse DFT by (−1)x+y

Source: http://www.imageprocessingbook.com – p.14/44

Page 14: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

A Simple Filter: Notch Filter (1)

We wish to force the average value of an image tozero:

F (0, 0) is the average value of the imageif size of the image is M × N then the centeredvalue of the Fourier transform is the average value(M

2 , N2 )

H(u, v) =

{

0 if (u, v) = (M2 , N

2 )

1 otherwise.

– p.15/44

Page 15: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

A Simple Filter: Notch Filter (2)

notch filter (constant function with a hole at the origin)

H(u, v) =

{

0 if (u, v) = (M2 , N

2 )

1 otherwise.

Source: http://www.imageprocessingbook.com – p.16/44

Page 16: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

Lowpass and Highpass Filter

Source: http://www.imageprocessingbook.com – p.17/44

Page 17: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

Smoothing Frequency-Domain Filters

G(u, v) = H(u, v)F (u, v)

Smoothing: attenuating specified range ofhigh-frequency components

Three types of lowpass filter:ideal (very sharp)Butterworth (tunable)Gaussian (very smooth)

– p.18/44

Page 18: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

Ideal Lowpass Filters (1)

H(u, v) =

{

1 if D(u, v) ≤ D0

0 if D(u, v) > D0

D0: nonnegative quantity

D(u, v): distance from a point (u, v) to the origin

origin: (M2 , N

2 ) (centered)

Then,

D(u, v) =

(u −M

2)2 + (v −

N

2)2

– p.19/44

Page 19: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

Ideal Lowpass Filters (2)

ideal filter (ILPF): all frequencies inside a circle ofradius D0 are passed with no attenuation

In our case:zero-phase-shift filterradially symmetric

Transition: cutoff frequency

Ringing behavior of the filterSource: http://www.imageprocessingbook.com – p.20/44

Page 20: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

Ideal Lowpass Filters: Example

Source: http://www.imageprocessingbook.com – p.21/44

laurentnajman
Texte tapé à la machine
460 (0.8%)
laurentnajman
Texte tapé à la machine
160 (2.2%)
laurentnajman
Texte tapé à la machine
160 (4.3%)
laurentnajman
Texte tapé à la machine
60 (6.9%)
laurentnajman
Texte tapé à la machine
30 (6.9%)
laurentnajman
Texte tapé à la machine
10 (13%)
laurentnajman
Texte tapé à la machine
Page 21: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

Cutoff Frequency

Compute circles that enclose specific amount of totalimage power PT

PT =

M−1∑

u=0

N−1∑

v=0

P (u, v)

P (u, v) = |F (u, v)|2 = R2(u, v) + I2(u, v)

α =100

PT

u

v

P (u, v)

Source: http://www.imageprocessingbook.com – p.22/44

Page 22: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

Ringing Effect of ILPF

Source: http://www.imageprocessingbook.com – p.23/44

Page 23: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

Butterworth Lowpass Filters

BLPF of order n, with a cutoff frequency distance D0 isdefined as

H(u, v) =1

1 + [D(u,v)D0

]2n

D(u, v) =

(u −M

2)2 + (v −

N

2)2

no clear cutoff between passed and filteredfrequencies

– p.24/44

Page 24: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

Butterworth Lowpass Filters (2)

Source: http://www.imageprocessingbook.com – p.25/44

Page 25: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

Butterworth Lowpass Filters: Examplen = 2, radii=5, 15, 30, 80, 230

Source: http://www.imageprocessingbook.com – p.26/44

Page 26: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

Ringing Effect of BLPF

Source: http://www.imageprocessingbook.com – p.27/44

Page 27: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

Gaussian Lowpass Filters (1)

The form of a gaussian lowpass filter GLPF in 2D is:

H(u, v) = e−D2(u,v)

2σ2

D(u, v) =

(u −M

2)2 + (v −

N

2)2

The inverse Fourier transform of a GLPF is also aGaussian

A spatial Gaussian filter will have no ringing

– p.28/44

Page 28: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

Gaussian Lowpass Filters (2)

σ: mesure of the spread of the Gaussian curve

Let σ = D0, then:

H(u, v) = e−D2(u,v)

2D20

Source: http://www.imageprocessingbook.com – p.29/44

Page 29: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

Gaussian Lowpass Filters: Example (1)n = 2, radii=5, 15, 30, 80, 230

Source: http://www.imageprocessingbook.com – p.30/44

Page 30: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

Gaussian Lowpass Filters: Example (2)

Source: http://www.imageprocessingbook.com – p.31/44

Page 31: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

Highpass Filters (1)

Highpass filter: image sharpening (low-frequencyattenuation)

In our case:zero-phase-shift filterradially symmetric

Hhp(u, v) = 1 − Hlp(u, v)

with:

Hlp(u, v): transfer function of the correspondinglowpass filter

Hhp(u, v): transfer function of the correspondinghighpass filter

– p.32/44

Page 32: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

Highpass Filters (2)

Source: http://www.imageprocessingbook.com – p.33/44

Page 33: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

Ideal Highpass Filters (1)

H(u, v) =

{

0 if D(u, v) ≤ D0

1 if D(u, v) > D0

D0: nonnegative quantity

D(u, v): distance from a point (u, v) to the origin

origin: (M2 , N

2 ) (centered)

Then,

D(u, v) =

(u −M

2)2 + (v −

N

2)2

– p.34/44

Page 34: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

Ideal Lowpass Filters: example

Source: http://www.imageprocessingbook.com – p.35/44

Page 35: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

Butterworth Highpass Filters

BLPF of order n, with a cutoff frequency distance D0 isdefined as

H(u, v) =1

1 + [ D0

D(u,v) ]2n

D(u, v) =

(u −M

2)2 + (v −

N

2)2

no clear cutoff between passed and filteredfrequencies

– p.36/44

Page 36: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

Butterworth Highpass Filters: Example

Source: http://www.imageprocessingbook.com – p.37/44

Page 37: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

Gaussian Highpass Filters

The form of a gaussian lowpass filter GLPF in 2D is:

H(u, v) = 1 − e−D2(u,v)

2D20

D(u, v) =

(u −M

2)2 + (v −

N

2)2

The inverse Fourier transform of a GLPF is also aGaussian

A spatial Gaussian filter will have no ringing

– p.38/44

Page 38: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

Gaussian Highpass Filters: Example

Source: http://www.imageprocessingbook.com – p.39/44

Page 39: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

Laplacian: Spatial Domain (1)

∇2f = ∂2f∂x2 + ∂2f

∂y2

∂2f∂x2 = f(x + 1, y) + f(x − 1, y) − 2f(x, y)

∂2f∂y2 = f(x, y + 1) + f(x, y − 1) − 2f(x, y)

∇2f = f(x + 1, y) + f(x − 1, y) + f(x, y + 1)+ f(x, y − 1) − 4f(x, y)

Source: http://www.imageprocessingbook.com – p.40/44

Page 40: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

Laplacian: Spatial Domain (2)

g(x, y) =

{

f(x, y) −∇2f(x, y) if the center coefficient is negative

f(x, y) + ∇2f(x, y) if the center coefficient is positive

Source: http://www.imageprocessingbook.com – p.41/44

Page 41: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

Laplacian: Frequency Domain (1)

F

[

dnf(x)

dxn

]

= (ju)nF (u)

Then,

F[

∂2f(x,y)∂x2 + ∂2f(x,y)

∂y2

]

= (ju)2 F (u, v) + (jv)2 F (u, v)

= −(u2 + v2)F (u, v)

Finally,F [∇2f(x, y)] = −(u2 + v2)F (u, v)

The Laplacian filter in the frequency domain is:

H(u, v) = −(u2 + v2)

– p.42/44

Page 42: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

Laplacian: Frequency Domain (2)

– p.43/44

Page 43: Image Enhancements in the Frequency Domain · 2013-10-15 · Frequency Domain Filtering Operation Frequency domain: space dened by values of the Fourier transform and its frequency

Laplacian: Example

– p.44/44