1 of 78

Digital Image Processing

Image Enhancement: �Filtering in the Frequency Domain

2 of 78

Jean Baptiste Joseph Fourier

Fourier was born in Auxerre,

France in 1768

    • Most famous for his work “La Théorie Analitique de la Chaleur” published in 1822
    • Translated into English in 1878: “The Analytic Theory of Heat”

Nobody paid much attention when the work was first published

One of the most important mathematical theories in modern engineering

2�of�54

3 of 78

The Big Idea

=

Any function that periodically repeats itself can be expressed as a sum of sines and cosines of different frequencies each multiplied by a different coefficient – a Fourier series

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

3�of�54

4 of 78

4�of�54

5 of 78

The Big Idea (cont…)

Notice how we get closer and closer to the original function as we add more and more frequencies

5�of�54

6 of 78

The Big Idea (cont…)

Frequency domain signal processing example in Excel

6�of�54

7 of 78

7�of�54

8 of 78

The Discrete Fourier Transform (DFT)

The Discrete Fourier Transform of f(x, y), for x = 0, 1, 2…M-1 and y = 0,1,2…N-1, denoted by F(u, v), is given by the equation:

for u = 0, 1, 2…M-1 and v = 0, 1, 2…N-1.

8�of�54

9 of 78

DFT & Images

The DFT of a two dimensional image can be visualised by showing the spectrum of the images component frequencies

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

DFT

9�of�54

10 of 78

DFT & Images

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

10�of�54

11 of 78

DFT & Images

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

11�of�54

12 of 78

DFT & Images (cont…)

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

DFT

Scanning electron microscope image of an integrated circuit magnified ~2500 times

Fourier spectrum of the image

12�of�54

13 of 78

DFT & Images (cont…)

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

13�of�54

14 of 78

DFT & Images (cont…)

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

14�of�54

15 of 78

The Inverse DFT

It is really important to note that the Fourier transform is completely reversible

The inverse DFT is given by:

for x = 0, 1, 2…M-1 and y = 0, 1, 2…N-1

15�of�54

16 of 78

The DFT and Image Processing

To filter an image in the frequency domain:

    • Compute F(u,v) the DFT of the image
    • Multiply F(u,v) by a filter function H(u,v)
    • Compute the inverse DFT of the result

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

16�of�54

17 of 78

17�of�54

18 of 78

Some Basic Frequency Domain Filters

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Low Pass Filter

High Pass Filter

18�of�54

19 of 78

Some Basic Frequency Domain Filters

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

19�of�54

20 of 78

Some Basic Frequency Domain Filters

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

20�of�54

21 of 78

Smoothing Frequency Domain Filters

Smoothing is achieved in the frequency domain by dropping out the high frequency components

The basic model for filtering is:

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

where F(u,v) is the Fourier transform of the image being filtered and H(u,v) is the filter transform function

Low pass filters – only pass the low frequencies, drop the high ones

21�of�54

22 of 78

Ideal Low Pass Filter

Simply cut off all high frequency components that are a specified distance D0 from the origin of the transform

changing the distance changes the behaviour of the filter

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

22�of�54

23 of 78

23�of�54

24 of 78

Ideal Low Pass Filter (cont…)

The transfer function for the ideal low pass filter can be given as:

where D(u,v) is given as:

24�of�54

25 of 78

Ideal Low Pass Filter (cont…)

Above we show an image, it’s Fourier spectrum and a series of ideal low pass filters of radius 5, 15, 30, 80 and 230 superimposed on top of it

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

25�of�54

26 of 78

Ideal Low Pass Filter (cont…)

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

26�of�54

27 of 78

Ideal Low Pass Filter (cont…)

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

27�of�54

28 of 78

Ideal Low Pass Filter (cont…)

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Original�image

Result of filtering with ideal low pass filter of radius 5

Result of filtering with ideal low pass filter of radius 30

Result of filtering with ideal low pass filter of radius 230

Result of filtering with ideal low pass filter of radius 80

Result of filtering with ideal low pass filter of radius 15

28�of�54

29 of 78

Ideal Low Pass Filter (cont…)

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Result of filtering with ideal low pass filter of radius 5

29�of�54

30 of 78

Ideal Low Pass Filter (cont…)

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Result of filtering with ideal low pass filter of radius 15

30�of�54

31 of 78

Butterworth Lowpass Filters

The transfer function of a Butterworth lowpass filter of order n with cutoff frequency at distance D0 from the origin is defined as:

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

31�of�54

32 of 78

Butterworth Lowpass Filter (cont…)

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Original�image

Result of filtering with Butterworth filter of order 2 and cutoff radius 5

Result of filtering with Butterworth filter of order 2 and cutoff radius 30

Result of filtering with Butterworth filter of order 2 and cutoff radius 230

Result of filtering with Butterworth filter of order 2 and cutoff radius 80

Result of filtering with Butterworth filter of order 2 and cutoff radius 15

32�of�54

33 of 78

Butterworth Lowpass Filter (cont…)

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Original�image

Result of filtering with Butterworth filter of order 2 and cutoff radius 5

33�of�54

34 of 78

Butterworth Lowpass Filter (cont…)

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Result of filtering with Butterworth filter of order 2 and cutoff radius 15

34�of�54

35 of 78

Gaussian Lowpass Filters

The transfer function of a Gaussian lowpass filter is defined as:

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

35�of�54

36 of 78

Gaussian Lowpass Filters (cont…)

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Original�image

Result of filtering with Gaussian filter with cutoff radius 5

Result of filtering with Gaussian filter with cutoff radius 30

Result of filtering with Gaussian filter with cutoff radius 230

Result of filtering with Gaussian filter with cutoff radius 85

Result of filtering with Gaussian filter with cutoff radius 15

36�of�54

37 of 78

Lowpass Filters Compared

Result of filtering with ideal low pass filter of radius 15

Result of filtering with Butterworth filter of order 2 and cutoff radius 15

Result of filtering with Gaussian filter with cutoff radius 15

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

37�of�54

38 of 78

Lowpass Filtering Examples

A low pass Gaussian filter is used to connect broken text

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

38�of�54

39 of 78

Lowpass Filtering Examples

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

39�of�54

40 of 78

Lowpass Filtering Examples (cont…)

Different lowpass Gaussian filters used to remove blemishes in a photograph

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

40�of�54

41 of 78

Lowpass Filtering Examples (cont…)

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

41�of�54

42 of 78

Lowpass Filtering Examples (cont…)

Original image

Gaussian lowpass filter

Processed image

Spectrum of original image

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

42�of�54

43 of 78

Sharpening in the Frequency Domain

Edges and fine detail in images are associated with high frequency components

High pass filters – only pass the high frequencies, drop the low ones

High pass frequencies are precisely the reverse of low pass filters, so:

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

43�of�54

44 of 78

Ideal High Pass Filters

The ideal high pass filter is given as:

where D0 is the cut off distance as before

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

44�of�54

45 of 78

Ideal High Pass Filters (cont…)

Results of ideal high pass filtering with D0 = 15

Results of ideal high pass filtering with D0 = 30

Results of ideal high pass filtering with D0 = 80

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

45�of�54

46 of 78

Butterworth High Pass Filters

The Butterworth high pass filter is given as:

where n is the order and D0 is the cut off distance as before

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

46�of�54

47 of 78

Butterworth High Pass Filters (cont…)

Results of Butterworth high pass filtering of order 2 with D0 = 15

Results of Butterworth high pass filtering of order 2 with D0 = 80

Results of Butterworth high pass filtering of order 2 with D0 = 30

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

47�of�54

48 of 78

Gaussian High Pass Filters

The Gaussian high pass filter is given as:

where D0 is the cut off distance as before

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

48�of�54

49 of 78

Gaussian High Pass Filters (cont…)

Results of Gaussian high pass filtering with D0 = 15

Results of Gaussian high pass filtering with D0 = 80

Results of Gaussian high pass filtering with D0 = 30

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

49�of�54

50 of 78

Highpass Filter Comparison

Results of ideal high pass filtering with D0 = 15

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

50�of�54

51 of 78

Highpass Filter Comparison

Results of Butterworth high pass filtering of order 2 with D0 = 15

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

51�of�54

52 of 78

Highpass Filter Comparison

Results of Gaussian high pass filtering with D0 = 15

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

52�of�54

53 of 78

Highpass Filter Comparison

Results of ideal high pass filtering with D0 = 15

Results of Gaussian high pass filtering with D0 = 15

Results of Butterworth high pass filtering of order 2 with D0 = 15

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

53�of�54

54 of 78

Highpass Filter Comparison

Results of ideal high pass filtering with D0 = 15

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

54�of�54

55 of 78

Highpass Filter Comparison

Results of Butterworth high pass filtering of order 2 with D0 = 15

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

55�of�54

56 of 78

Highpass Filter Comparison

Results of Gaussian high pass filtering with D0 = 15

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

56�of�54

57 of 78

Highpass Filtering Example

Original image

Highpass filtering result

High frequency emphasis result

After histogram equalisation

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

57�of�54

58 of 78

Laplacian In The Frequency Domain

Laplacian in the frequency domain

2-D image of Laplacian in the frequency domain

Inverse DFT of Laplacian in the frequency domain

Zoomed section of the image on the left compared to spatial filter

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

58�of�54

59 of 78

Frequency Domain Laplacian Example

Original image

Laplacian filtered image

Laplacian image scaled

Enhanced image

59�of�54

60 of 78

Fast Fourier Transform

The reason that Fourier based techniques have become so popular is the development of the Fast Fourier Transform (FFT) algorithm

Allows the Fourier transform to be carried out in a reasonable amount of time

Reduces the amount of time required to perform a Fourier transform by a factor of 100 – 600 times!

60�of�54

61 of 78

Frequency Domain Filtering & Spatial Domain Filtering

Similar jobs can be done in the spatial and frequency domains

Filtering in the spatial domain can be easier to understand

Filtering in the frequency domain can be much faster – especially for large images

61�of�54

62 of 78

DFT Properties: (1) Separability

  • The 2D DFT can be computed using 1D DFTs:

Forward DFT:

This is because

the exponential

kernel is

separable!

63 of 78

DFT Properties: (1) Separability (cont’d)

  • Using the kernel separability:

  • Let’s set:

  • Then:

2D DFT steps:

1. Compute F1(x,v)

2. Compute F(u,v)

1

1

64 of 78

DFT Properties: (2) Periodicity

  • The DFT and its inverse are periodic with period N:

65 of 78

DFT Properties: (3) Symmetry

66 of 78

DFT Properties: (4) Translation

f(x,y) F(u,v)

)

N

  • Translation in spatial domain:
  • Translation in frequency domain:

67 of 78

DFT Properties: (5) Rotation

  • Rotating f(x,y) by θ rotates F(u,v) by θ

68 of 78

DFT Properties: (6) Addition/Multiplication

69 of 78

DFT Properties: (7) Scale

70 of 78

DCT(Discreate Cosine Transform)

70�of�54

71 of 78

71�of�54

72 of 78

72�of�54

73 of 78

73�of�54

74 of 78

74�of�54

75 of 78

75�of�54

76 of 78

76�of�54

77 of 78

77�of�54

78 of 78

78�of�54