SYDE 575: Introduction to Image Processing

55
SYDE 575: Introduction to Image Processing Spatial-Frequency Domain: Implementations Textbook: Chapter 4

description

Spatial-Frequency Domain: Implementations Textbook: Chapter 4. SYDE 575: Introduction to Image Processing. Filtering in Spatial and Spatial-Frequency Domains. Basic spatial filtering is essentially 2D discrete convolution between an image f and filter function h. - PowerPoint PPT Presentation

Transcript of SYDE 575: Introduction to Image Processing

Page 1: SYDE 575: Introduction to Image Processing

SYDE 575: Introduction to Image Processing

Spatial-Frequency Domain: Implementations

Textbook: Chapter 4

Page 2: SYDE 575: Introduction to Image Processing

Filtering in Spatial and Spatial-Frequency Domains

Basic spatial filtering is essentially 2D discrete convolution between an image f and filter function h

( , ) ( , ) ( , )g x y f x y h x y= *

Convolution in spatial domain becomes multiplication in frequency domain

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

Page 3: SYDE 575: Introduction to Image Processing

Spatial-Frequency Implementations

We will discuss these implementations:

• Low pass filters: ideal, Butterworth, Gaussian

• High pass filters: ideal, Butterworth, Gaussian

• Edge enhancement: high boost filtering

• HVS modelling: Difference of Gaussians (DoG), Gabor, Laplacian of Gaussian

• Periodic noise filtering (Section 5.4)

Page 4: SYDE 575: Introduction to Image Processing

Blurring/Noise reduction

Noise characterized by sharp transitions in image intensity

Such transitions contribute significantly to high frequency components of Fourier transform

Intuitively, attenuating certain high frequency components result in blurring and reduction of image noise

Page 5: SYDE 575: Introduction to Image Processing

Ideal LPF

Cuts off all high-frequency components at a distance greater than a certain distance from origin (D0: cutoff frequency)

0

0

1, if D (u,v) D( , )

0, if D (u,v) DH u v

£ì=í >î

Page 6: SYDE 575: Introduction to Image Processing

Visualization

Source: Gonzalez and Woods

Page 7: SYDE 575: Introduction to Image Processing

Effect of Different Cutoff Frequencies

Source: Gonzalez and Woods

Page 8: SYDE 575: Introduction to Image Processing

Effect of Different Cutoff Frequencies

Source: Gonzalez and Woods

Page 9: SYDE 575: Introduction to Image Processing

Effect of Different Cutoff Frequencies

As cutoff frequency decreases Image becomes more blurred Noise becomes more reduced Analogous to larger spatial filter sizes

Noticeable ringing artifacts that increase as the amount of high frequency components removed is increased

Why ringing?

Page 10: SYDE 575: Introduction to Image Processing

Why is there ringing?

Ideal low-pass filter function is a rectangular function

The inverse Fourier transform of a rectangular function is a sinc function

Convolution of a sinc and a step function generates ringing on both sides of the edge

Page 11: SYDE 575: Introduction to Image Processing

Ringing

Source: Gonzalez and Woods

Page 12: SYDE 575: Introduction to Image Processing

Butterworth LPF

Transfer function does not have sharp discontinuity establishing cutoff between passed and filtered frequencies

Cutoff frequency D0 defines point at which

H(u,v)=0.5 Similar to exponential LPF

[ ]2

0

1( , )

1 ( , ) /n

H u vD u v D

=+

Page 13: SYDE 575: Introduction to Image Processing

Butterworth LPF

Source: Gonzalez and Woods

Page 14: SYDE 575: Introduction to Image Processing

Spatial Representations

Source: Gonzalez and Woods

Tradeoff between amount of smoothing and ringing

Page 15: SYDE 575: Introduction to Image Processing

Butterworth LPFs of Different Orders

Source: Gonzalez and Woods

Page 16: SYDE 575: Introduction to Image Processing

Gaussian LPF

This is another form of a Gaussian filter, as used by Gonzalez & Woods (textbook)

Transfer function is smooth, like Butterworth filter

Gaussian in frequency domain remains a Gaussian in spatial domain

Advantage: No ringing artifacts

2 20( , ) / 2( , ) D u v DH u v e -=

Page 17: SYDE 575: Introduction to Image Processing

Gaussian LPF

Source: Gonzalez and Woods

Page 18: SYDE 575: Introduction to Image Processing

Gaussian LPF

Source: Gonzalez and Woods

Page 19: SYDE 575: Introduction to Image Processing

Spatial-Frequency High Pass Filters (HPFs)

• HPFs are effectively the opposite of LPFs

• High pass filtering in the spatial-frequency domain is related to low pass filtering

HHP(u,v) = 1 – HLP(u,v)

hHP(x,y) = d(x,y) – hLP (x,y)

• Note: DC gain is zero for a HPF

Page 20: SYDE 575: Introduction to Image Processing

Impact of High Pass Filtering

Edges and fine detail characterized by sharp transitions in image intensity

Such transitions contribute significantly to high frequency components of Fourier transform

Intuitively, attenuating low frequency components and preserving high frequency components will retain image intensity edges

Page 21: SYDE 575: Introduction to Image Processing

HPF Transfer Functions

Ideal HPF0

0

0 if ( , )( , )

1 if ( , )

D u v DH u v

D u v D

£ì=í >î

Butterworth HPF

[ ]2

0

1( , )

1 / ( , )n

H u vD D u v

=+

Gaussian HPF2 2

0( , ) / 2( , ) 1 D u v DH u v e -= -

Page 22: SYDE 575: Introduction to Image Processing

HPF Transfer Functions

Page 23: SYDE 575: Introduction to Image Processing

Spatial Representations of HPFs

Page 24: SYDE 575: Introduction to Image Processing

Ideal HPF Filtering

Page 25: SYDE 575: Introduction to Image Processing

Butterworth HPF Filtering

Page 26: SYDE 575: Introduction to Image Processing

Gaussian HPF Filtering

Page 27: SYDE 575: Introduction to Image Processing

Observations of HPFs

As with ideal LPF, ideal HPF shows significant ringing artifacts

Second-order Butterworth HPF shows sharp edges with minor ringing artifacts

Gaussian HPF shows good sharpness in edges with no ringing artifacts

Page 28: SYDE 575: Introduction to Image Processing

Spatial-Frequency Edge Enhancement

• Edge enhancement can be performed directly in the spatial-frequency domain

• Example: high boost filtering (unsharp masking)

Page 29: SYDE 575: Introduction to Image Processing

High frequency emphasis

Advantageous to accentuate enhancements made by high-frequency components of image in certain situations (e.g., image visualization)

Solution: multiply high-pass filter by a constant and add offset so zero frequency term not eliminated

g(x,y) = f(x,y) + k gHPF(x,y)

As discussed earlier, this is referred to as high-boost filtering

Page 30: SYDE 575: Introduction to Image Processing

High Boost Filtering

In spatial domain:g(x,y) = f(x,y) + k gHPF(x,y)

Impulse response:

h(x,y) = d(x,y) + k hHPF(x,y)

Transfer function in spatial-frequency domain:

H(u,v) = 1 + k HHPF(u,v)or:

H(u,v) = 1 + kHHPF(u,v) = 1 + k(1- HLPF(u,v))

= (1+k) - kHLPF(u,v)

Recall: Set k=1 for unsharp masking

Page 31: SYDE 575: Introduction to Image Processing

Results

Source: Gonzalez and Woods

Page 32: SYDE 575: Introduction to Image Processing

Examples of Frequency Domain Filtering

Source: Gonzalez and Woods

Page 33: SYDE 575: Introduction to Image Processing

Human Visual System Models

• For a generic spatial-frequency image enhancement filter, what should the transfer function look like?

1) DC gain is typically reduced so 0<H(u)<12) H(u) approaches zero as u increases3) H(u) > 1 for frequency range where signal

dominates

• Sketch:

Page 34: SYDE 575: Introduction to Image Processing

Model of HVS

• Light entering the eye is processed by two steps

1) Cornea/Lens H1(u): modelled as LPF e.g., Gaussian

2) Retina H2(u): modelled as edge enhancement e.g., 1-Laplacian

Combined: H(u) = H1(u) H2(u)= (1+(2pu/a)2)

e-2p2u2s2

Sketch:

Page 35: SYDE 575: Introduction to Image Processing

Difference of Gaussians

• There are a number of Gaussian-based functions that mimic lateral inhibition

• Difference of Gaussians takes the difference of two Gaussians with different s

H(u) = A e-2p2u2s12 - Be-2p2u2s2

2

With A>B and s1<< s2

Sketch in frequency and time domains

• Can vary s1 and s2 to create filter bank with varying peak frequencies

Page 36: SYDE 575: Introduction to Image Processing

Gabor Filter

• Gabor is a Gaussian band pass filter

H(u) = (A/2) e-2p2u2s12 * [ d(u-up) + d(u+up)]

• In time domain, a Gaussian-modulated sinusoid (real part of Gabor filter)

h(x) = A/(s(2p)0.5) e-0.5(x/s)2cos(2pupx)

Sketch in frequency and time

• Similar shape as Difference of Gaussians, but with ringing

• Note: complex form of filter used for texture feature extraction

Page 37: SYDE 575: Introduction to Image Processing

Laplacian of a Gaussian

• Consider the Marr-Hildreth operator i.e., a Laplacian of a Gaussian

H(u) = (-j2pu)2 e-2p2u2s2 = 4p2u2 e-2p2u2s2

• Sketch in time and frequency domains

• What is the impact of this filter? Why?

Page 38: SYDE 575: Introduction to Image Processing

Periodic Noise Reduction

Typically occurs from electrical or electromechanical interference during image acquisition

Spatially dependent noise Example: spatial sinusoidal noise

Page 39: SYDE 575: Introduction to Image Processing

Example

Source: Gonzalez and Woods

Page 40: SYDE 575: Introduction to Image Processing

Observations

Symmetric pairs of bright spots appear in the Fourier spectra

Why? Fourier transform of cosine function is

the sum of a pair of impulse functions

cos(2pu0x) <-> 0.5[d(u + u0) + d(u – u0)]

Intuitively, sinusoidal noise can be reduced by attenuating these bright spots

Page 41: SYDE 575: Introduction to Image Processing

Bandreject Filters

Removes or attenuates a band of frequencies about the origin of the Fourier transform

Sinusoidal noise may be reduced by filtering the band of frequencies upon which the bright spots associated with period noise appear

Page 42: SYDE 575: Introduction to Image Processing

Example: Ideal Bandreject Filters

Ideal bandreject filter

0

0 0

0

1 if ( , )2

( , ) 0 if ( , )2 2

1 if ( , )2

WD u v D

W WH u v D D u v D

WD u v D

ì < -ïïï= - £ £ +íïï > +ïî

Page 43: SYDE 575: Introduction to Image Processing

Example

Source: Gonzalez and Woods

Page 44: SYDE 575: Introduction to Image Processing

Notch Reject Filters

Idea: Sinusoidal noise appears as bright spots

in Fourier spectra Reject frequencies in predefined

neighborhoods about a center frequency In this case, center notch reject filters

around frequencies coinciding with the bright spots

Page 45: SYDE 575: Introduction to Image Processing

Some Notch Reject Filters

Source: Gonzalez and Woods

Page 46: SYDE 575: Introduction to Image Processing

Example: Moire pattern reduction

Source: Gonzalez and Woods

Page 47: SYDE 575: Introduction to Image Processing

Homomorphic Filtering

Image can be modeled as a product of illumination (i) and reflectance (r)

( , ) ( , ) ( , )f x y i x y r x y=

Unlike additive noise, can not operate on frequency components of illumination and reflectance separately

[ ] [ ] [ ]( , ) ( , ) ( , )f x y i x y r x yÁ ¹Á Á

Page 48: SYDE 575: Introduction to Image Processing

Homomorphic Filtering

Idea: What if we take the logarithm of the image?

[ ] [ ] [ ]ln ( , ) ln ( , ) ln ( , )f x y i x y r x yÁ =Á +Á

ln ( , ) ln ( , ) ln ( , )f x y i x y r x y= +

Now the frequency components of i and r can be operated on separately

Page 49: SYDE 575: Introduction to Image Processing

Homomorphic Filtering Framework

Source: Gonzalez and Woods

Page 50: SYDE 575: Introduction to Image Processing

Homomorphic Filtering: Image Enhancement

Simultaneous dynamic range compression (reduce illumination variation) and contrast enhancement (increase reflectance variation)

Illumination component characterized by slow spatial variations (low spatial frequencies)

Reflectance component characterized by abrupt spatial variations (high spatial frequencies)

Page 51: SYDE 575: Introduction to Image Processing

Homomorphic Filtering: Image Enhancement

Can be accomplished using a high frequency emphasis filter in log space DC gain of 0.5 (reduce illumination

variations) High frequency gain of 2 (increase

reflectance variations) Output of homomorphic filter

( )2( , ) ( , ) ( , )g x y i x y r x y»

Page 52: SYDE 575: Introduction to Image Processing

Example

Source: Gonzalez and Woods

Page 53: SYDE 575: Introduction to Image Processing

Homomorphic Filtering: Noise Reduction

Multiplicative noise model

( , ) ( , ) ( , )f x y s x y n x y=

signal noise

Transforming into log space turns multiplicative noise to additive noise

ln ( , ) ln ( , ) ln ( , )f x y s x y n x y= + Low-pass filtering can now be applied to

reduce noise

Page 54: SYDE 575: Introduction to Image Processing

Example

Source: Jernigan, 2003

O riginal M ultiplicative Noise

Page 55: SYDE 575: Introduction to Image Processing

Example

Source: Jernigan, 2003

Hom om orphic LPF