8
4/28/2008 1 Frequency domain filtering fundamentals Spring 2008 ELEN 4304/5365 DIP 1 by Gleb V. Tcheslavski: [email protected] http://ee.lamar.edu/gleb/dip/index.htm Preliminaries For a digital image f(x,y) the basic filtering equation is { } 1 { } 1 (, ) (,) (,) gxy HuvFuv = Where H(u,v) and F(u,v) are DFTs of the image and of the filter. Their product is defined by array (element-by-element) multiplication. Specifications of H(u,v) are simplified considerably when using functions symmetric about their centers This requires Spring 2008 ELEN 4304/5365 DIP 2 when using functions symmetric about their centers. This requires that F(u,v) is also centered, which is accomplished by multiplying the input image by (-1) x+y before computing its transform.

04 1 - frequency domain filtering fundamentals

Embed Size (px)

Citation preview

4/28/2008

1

Frequency domain filtering fundamentals

Spring 2008 ELEN 4304/5365 DIP 1

by Gleb V. Tcheslavski: [email protected]

http://ee.lamar.edu/gleb/dip/index.htm

Preliminaries For a digital image f(x,y) the basic filtering equation is

{ }1 { }1( , ) ( , ) ( , )g x y H u v F u v−= ℑ

Where H(u,v) and F(u,v) are DFTs of the image and of the filter. Their product is defined by array (element-by-element) multiplication. Specifications of H(u,v) are simplified considerably when using functions symmetric about their centers This requires

Spring 2008 ELEN 4304/5365 DIP 2

when using functions symmetric about their centers. This requires that F(u,v) is also centered, which is accomplished by multiplying the input image by (-1)x+y before computing its transform.

4/28/2008

2

Simple filters

Considering the following image with centered (and scaled) DFT

Spring 2008 ELEN 4304/5365 DIP 3

Simple filtersOne of the simplest filters would be H(u,v) having 0 at the center and 1 elsewhere. Such filter will reject the DC (constant) term and l thi l h dleave everything else unchanged.

Since the DC term represents an average intensity, setting it to zero results in reduction of average intensity to zero.

Spring 2008 ELEN 4304/5365 DIP 4

Therefore, the resulting image appears darker.Actually, aero average implies negative intensities.

4/28/2008

3

Simple filters

Low frequencies in the transform are related to slowly varying intensity components of image. High frequencies are caused by sharp transitions in intensity (edges, noise).

Therefore, LPF will blur an image reducing details (and noise).

HPF will enhance sharp details but cause reduction in contrast since it eliminates DC component. Adding a small constant to a HPF d t ff t h i ti b t t li i ti

Spring 2008 ELEN 4304/5365 DIP 5

HPF does not affect sharpening properties but prevents elimination of DC term and, thus, preserves contrast.

Simple filtersa=0.85

Spring 2008 ELEN 4304/5365 DIP 6

4/28/2008

4

Zero‐padding 

Periodicity implied by DFT leads to a “wraparound” error: data from adjacent periods aliases leading to incorrect results of convolution.To avoid “wraparounds”, convolved functions must be zero padded

Spring 2008 ELEN 4304/5365 DIP 7Correct result

be zero‐padded.

More on zero‐padding

Sample image Blurred without padding Blurred with padding

Spring 2008 ELEN 4304/5365 DIP 8

p g p g p g

Blurred images are not uniform: top white edges are blurred but side edges are not (without zero‐padding). The zero‐padding leads to an expected result.

4/28/2008

5

More on zero‐padding

Image 

Image 

Spring 2008 ELEN 4304/5365 DIP 9

No padding With padding

Due to periodicity implicit while using DFT, a spatial filter passing through the top edge of the image encompasses a part of the image and also a part of the bottom of the periodic image right above it. Padding helps to avoid this…

Zero‐padding and ringing

Considering an ideal LPF and its spatial representation obtained via multiplication by (-1)u and IDFT, we notice that zero-padding will lead to discontinuities.If we compete DFT of zero-padded filter (to obtain its f h t i ti )

Spring 2008 ELEN 4304/5365 DIP 10

frequency characteristic), ringing (Gibbs?) will occur.Ideal – infinite sinc –truncation – ringing!

4/28/2008

6

Appearance of ringingResults of filtering with ILPF… Notice ringing

We cannot use ideal filters AND zero-padding at the same time!

ringing appearance.

Spring 2008 ELEN 4304/5365 DIP 11

We cannot use ideal filters AND zero padding at the same time!One approach would be to zero-pad images and then create filters (of the same zero-padded size) in frequency domain. However, this will produce (insignificant though) wraparounds since the filter won’t be zero-padded.

On phase angleSince DFT of an image is a complex array, say

( , ) ( , ) ( , )F u v R u v jI u v= +The filtered image would be

{ }1( , ) ( , ) ( , ) ( , ) ( , )g x y H u v R u v jH u v I u v−= ℑ +

We are interested in filters affecting the real and imaginary parts equally –

Spring 2008 ELEN 4304/5365 DIP 12

ag a y pa ts equa yzero-phase-shift filters.Even small changes in the phase angle may have drastic effect!

Phase multiplied by 0.5 Phase multiplied by 0.25

4/28/2008

7

Summary of steps1. For the input image f(x,y) of size MxN, form the zero-padded image fp(x,y) of size PxQ (typically P = 2M, Q = 2N), where

2 1 2 1P M Q N≥ ≥2 1; 2 1P M Q N≥ − ≥ −2. Obtain fc(x,y) multiplying fp(x,y) by (-1)x+y to center its transform;3. Compute the DFT of the fc(x,y);4. Generate a real, symmetric filter function H(u,v) of size PxQ with center at coordinates (P/2, Q/2);5. Form the product G(u,v) = H(u,v) F(u,v) via array multiplication;6 Ob i h d i

Spring 2008 ELEN 4304/5365 DIP 13

6. Obtain the processed image

7. Finally, extract g(x,y) – the MxN region from the top left quadrant of gp(x,y).

{ }( )( )1( , ) ( , ) 1 x ypg x y real G u v +−⎡ ⎤= ℑ −⎣ ⎦

Summary of stepsThe original image – zero-padded –scaled by (-1)x+y –scaled by ( 1)DFT – DFT of LPF – DFT of filtering result – IDFT –extracted filtered image.

Spring 2008 ELEN 4304/5365 DIP 14

4/28/2008

8

Spatial vs. Frequency domainsThe link between filtering in spatial and in frequency domains is the convolution theorem...

( ) ( )h H⇔( , ) ( , )h x y H u v⇔However, DFT implements a circular convolution.

Considering next the image and its spectrum

Spring 2008 ELEN 4304/5365 DIP 15

(magnitude of its DFT) of size 600 x 600

Spatial vs. Frequency domainsWe attempt to use a 3x3 Sobel mask…Therefore, we need to zero-pad both the image and the mask to size of 602 x 602 (keeping the mask at the center to preserve symmetry) to avoid wraparounds.

h fil f

Spring 2008 ELEN 4304/5365 DIP 16

The filter I n frequency domain…Results of frequency-domain filtering and spatial filtering are same.