The Fourier Transform II Image Analysis Filtering in the frequency - - PowerPoint PPT Presentation

the fourier transform ii image analysis
SMART_READER_LITE
LIVE PREVIEW

The Fourier Transform II Image Analysis Filtering in the frequency - - PowerPoint PPT Presentation

The Fourier Transform II Image Analysis Filtering in the frequency domain The Fourier transform and its inverse allows us to jump back and forth between the spatial and frequency domains. Niclas Brlin niclas.borlin@cs.umu.se By manipulating


slide-1
SLIDE 1

Image Analysis

Filtering in the frequency domain Niclas Börlin niclas.borlin@cs.umu.se

Department of Computing Science Umeå University

February 3, 2009

Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 1 / 24

The Fourier Transform II

The Fourier transform and its inverse allows us to jump back and forth between the spatial and frequency domains. By manipulating the spectra in the frequency domain we can construct the filters we want more intuitively than if we were to construct the filter in the spatial domain.

Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 2 / 24

Filtering in the frequency domain

The basic filtering equation is g(x, y) = F−1{H(u, v)F(u, v)}. where F(u, v) is the DFT of the input image f(x, y), H(u, v) is a filter function or simply filter and g(x, y) is the filtered output image. The array H(u, v) contains the filter coefficient and must be of the same size as F(u, v). We assume the spectra is shifted such that the zero frequency is located at F(M/2, N/2).

Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 3 / 24

Filter types

A filter that attenuates high frequencies while passing low frequencies is called a lowpass filter. Lowpass filters are usually used for smoothing. A filter that does not effect high frequencies is called a highpass filter. Highpass filters are usually used for sharpening. Furthermore, bandpass (bandreject) filters work on specific frequency bands. Finally, notch filters work on specific frequencies.

Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 4 / 24

slide-2
SLIDE 2

Lowpass vs. highpass filters

With suitable scaling the low pass filter has the property that H(0, 0) = 1, i.e. the DC component is not changed. A high pass filter Hhp can then obtained from Hhp(u, v) = 1 − Hlp(u, v).

Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 5 / 24

Ideal filters

An ideal filter has the property that all frequencies above (or below) a cut off frequency D0 are set to zero H(u, v) = 1 if D(u, v) ≤ D0

  • therwise

, where D(u, v) =

  • (u/P − 1/2)2 + (v/Q − 1/2)21/2

. [Q,P]=size(I); u=(0:P-1)/P-1/2; v=(0:Q-1)/Q-1/2; [uu,vv]=meshgrid(u,v); H=sqrt(uu. ˆ 2+vv. ˆ 2)<=D0;

Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 6 / 24

Ideal lowpass filtering

f(x, y) g(x, y) H(u, v) h(x, y)

Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 7 / 24

Ideal highpass filtering

f(x, y) g(x, y) H(u, v) h(x, y)

Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 8 / 24

slide-3
SLIDE 3

Ideal filters and “ringing”

The spatial version h(x, y) of an ideal filter has severe "ringing". By the convolution theorem we know that the multiplication F(u, v)H(u, v) in the frequency domain corresponds to convolution f(x, y) ∗ h(x, y) in the spatial domain. This explain the observed ringing in the filtered image. Due to the ringing problem, ideal filters are rarely used.

Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 9 / 24

Gaussian filters

To avoid ringing we could use smooth filters. We know that a Gaussian function is smooth in both domains. The filter H(u, v) = e−D2(u,v)/2D2 where D(u, v) is the distance from the (0, 0) frequency, would be expected to yield smooth response. At distance D0 from the zero frequency the response of the filter is about 60% of the value at (0, 0).

Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 10 / 24

Gaussian lowpass filtering

f(x, y) g(x, y) H(u, v) h(x, y)

Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 11 / 24

Gaussian highpass filtering

f(x, y) g(x, y) H(u, v) h(x, y)

Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 12 / 24

slide-4
SLIDE 4

Butterworth filter

Another version of smoothing/sharpening filters are the Butterworth filter. A Butterworth filter of order n and cutoff frequency D0 is defined as H(u, v) = 1 1 + [D(u, v)/D0]2n . An advantage with the Butterworth filter is that we can control the sharpness of the filter with the order.

Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 13 / 24

The Laplacian in the frequency domain

It can be shown that the Laplacian can be implemented in the frequency domain using the filter H(u, v) = −4π2(u2 + v2),

  • r, with respect to the center of the frequency rectangle, using

the filter H(u, v) = −4π2[(u − P/2)2 + (v − Q/2)2] = −4π2D2(u, v) . The Laplacian image is obtain as ∇2f(x, y) = F−1{H(u, v)F(u, v)}

Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 14 / 24

The Laplacian in the frequency domain

As we have seen enhancement is achieved using equation g(x, y) = f(x, y) + c∇2f(x, y) here c = −1 because H(u, v) is negative. In the frequency domain this is written g(x, y) = F−1{F(u, v) − H(u, v)F(u, v)} = F−1{[1 − H(u, v)]F(u, v)} = F−1{[1 + 4π2D2(u, v)]F(u, v)}

Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 15 / 24

Gaussian bandpass filtering

The filter H(u, v) = e−D2(u,v)/2D2

1 − e−D2(u,v)/2D2 2

is called a Gaussian bandpass filter. It is the difference between two Gaussian filters.

Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 16 / 24

slide-5
SLIDE 5

Gaussian bandpass filtering, D1 = 0.2, D2 = 0.1

f(x, y) g(x, y) H(u, v) h(x, y)

Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 17 / 24

Homomorphic Filtering

Recall that an image can be expressed as a product of illumination and reflectance components f(x, y) = i(r, x)r(x, y) By using the logarithm z(x, y) = ln f(x, y) the multiplicative relationship will become additative z(x, y) = ln f(x, y) = ln i(x, y) + ln r(x, y) Then we can calculate the Fourier transform of z(x, y) as Z(u, v) = Fi(u, v) + Fr(u, v) Z(u, v) is then filtered with H(u, v) forming S(u, v) that is re-transformed to the spatial domain as s(x, y) To reverse the logarithm the following is used g(x, y) = es(x,y)

Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 18 / 24

Homomorphic Filtering

It is often assumed that the illumination component is characterized by slower intensity changes than the reflectance component. Thus a filter H(u, v) that allows us to adjust the low and high frequencies separately is often used when doing homomorphic filtering One such example is a slightly modified Gaussian high pass filter H(u, v) = (γH − γL)[1 − e−cD2(u,v)/D2

0] + γL

The parameter γL allows us to adjust how much of the low frequencies to keep while γH gives us control over the high frequencies

Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 19 / 24

Homomorphic filtering

c = 1, D0 = 0.1, γL = 0.5, γH = 1.5

Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 20 / 24

slide-6
SLIDE 6

Padding

When filtering in the frequency domain and transforming the filtered image back to the spatial domain there sometimes appear artifacts along the edge of the image This is due to the periodic nature of the discrete Fourier transform Suppose f(x) has spectra F(s) Sampling f(x) with ∆x indicates that F(s) is copied with period

1 ∆x

In the same way: The discrete version of the spectra F(s) with resolution ∆s copies f(x) with a period of

1 ∆s

A filtering by multiplying with H(s) will produce a convolution with h(x) in the spatial domain At the edges of f(x) parts of the adjacent instances of f(x) will be convolved into the image, since h(x) has an extension in the spatial domain

Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 21 / 24

Padding

Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 22 / 24

Padding

The problems of border effects when doing filtering in the frequency domain is avoided by padding the image prior to transforming it to the frequency domain An image of size A × B must be padded to size P = 2A + 1 and Q = 2B + 1 prior to filtering H(u, v) must be transformed to the spatial domain, padded to size P × Q and re-transformed to the frequency domain After filtering an re-transformation to the spatial domain only a the part that corresponds to the original A × B is kept

Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 23 / 24

Padded filtering

Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 24 / 24