62
Transforms and Frequency Filtering Khalid Niazi Centre for Image Analysis Swedish University of Agricultural Sciences Uppsala University

Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

Transforms and

Frequency Filtering

Khalid NiaziCentre for Image Analysis

Swedish University of Agricultural Sciences

Uppsala University

Page 2: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

2

[email protected]

Reading Instructions

• Chapter 4: Image Enhancement in the

Frequency Domain

• Book: Digital Image Processing by Gonzalez &

Woods, Third Edition, 2007

Page 3: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

3

Image processing

g(x, y) = T[f(x, y)]

• Original image f.

• Result image g after transformation T.

• T can be performed

– point-wise (gray-level transformation)

1 x 1

– locally (in a small neighborhood)

m x n

– globally (the whole image)

M X N

[email protected]

Page 4: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

4

Image representations

• An image is a function of x and y. f(x, y)

• One possible way to investigate its properties is to display the function values as grey-level

intensities; this is the “normal” representation.

• Another possibility is to transform the function values, e.g., to spatial frequencies through the

Fourier transform. It is still the same image, but in a different representation.

• This gives a partitioning of the frequencies in the image.

[email protected]

Page 5: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

5

Frequency domain representation

• We need to know

– Frequency

– Sinusoids

– Euler’s formula

– …

[email protected]

Page 6: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

6

Frequency domain representation

• Frequency: Cycles per second

• Sinusoids: Common name for Cosine and Sine

• Euler's formula

[email protected]

Page 7: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

7

Frequency domain representation

• Using Euler’s formula one can write a Sinusoid

as,

0

[email protected]

Page 8: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

8

Frequency domain representation

x(t) = x1(t) + x2(t) + x3(t) + x4(t)

x1(t) = 10 cos(2*pi*1*t+pi/32)

x2(t) = 6 cos(2*pi*1.5*t+pi/10)

x3(t) = 4 cos(2*pi*2.7*t+pi/7)

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

x4(t) = 2 cos(2*pi*3.4*t+pi/13)

time

[email protected]

Page 9: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

9

Frequency domain representation

-4 -3 -2 -1 0 1 2 3 40

0.5

1

1.5

2

2.5

3

3.5

4

4.5

5

frequency

[email protected]

Page 10: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

10

Frequency domain representation

• Conjugate symmetric pair of points in the

frequency domain of a signal corresponds to a

sinusoid in the spatial domain

• A one-dimensional sinusoid has frequency,

phase, and amplitude

• No time information in the frequency domain

[email protected]

Page 11: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

11

Frequency domain representation

• Y[x, y] = sin[2π(Ux+ Vy)]

• Where x and y are horizontal and vertical dimensions

of the image Y. U and V represents the frequencies

along these dimensions.

• Here the image has two frequencies, i.e., horizontal

and vertical frequencies

• MATLAB demonstration

[email protected]

Page 12: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

12

Frequency domain representation

• Conjugate symmetric pair of points in the

frequency domain of an image corresponds to a

two-dimensional sinusoid in the spatial domain

• A one-dimensional sinusoid has frequency,

phase, and amplitude and two dimensional

sinusoid also has a direction

• Two-dimensional sinusoids are directional in

nature

[email protected]

Page 13: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

13

Fourier transform

• F(u, v) is generally complex:

• F(u, v) = ℜ(u, v) + ℑ(u, v) = |F(u, v)| exp ( φ(u, v))

• ℜ(u, v) is the real component of F(u, v).

• ℑ(u, v) is the imaginary component of F(u, v).

• |F(u, v)| is the magnitude function, also called the Fourier spectrum.

• φ(u, v) is the phase angle.

• F(u, v) is composed of an infinite sum of sine and cosine terms, where u

and v determines the frequency of its corresponding sine-cosine pair.

[email protected]

Page 14: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

14

Summation of Fourier frequency

terms to fit a step function

[email protected]

Page 15: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

15

Display of Fourier images

• The magnitude function, or Fourier spectrum,

• |F(u, v)|

• can be displayed as an intensity function, where the brightness is

• proportional to the amplitude.

• The spectrum most often has a large dynamic range, e.g.,

• 0–2.500.000. Only the brightest parts of the spectrum are visible.

• By a logarithmic transform an increase in visible detail is possible:

• D(u, v) = c log(1 + |F(u, v)|)

[email protected]

Page 16: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

16

Display of Fourier images

[email protected]

Page 17: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

17

The Fourier spectrum |F(u, v)|

• F(0, 0) is the mean grey-level in the image, i.e., the lowest frequency.

• The farther away from (u, v) = (0, 0) we get, the higher the frequencies

represented by F(u, v) are.

• F(u, v) contains information about low frequencies (areas with slowly

changing grey-level) if (u, v) is close to (0, 0).

• F(u, v) contains information about high frequencies (abrupt changes in

grey-level, such as edges and noise) if (u, v) is far away from (0, 0).

• F(0, 0) is usually centered in the image showing the Fourier spectrum.

[email protected]

Page 18: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

18

Properties of the Fourier transform

• Separability

• Translation

• Periodicity

• Conjugate Symmetry

• Rotation

• Convolution

[email protected]

Page 19: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

19

Separability

• The separability property is a great advantage for images with M = N.

• F(u, v) or f(x, y) can be obtained by two successive applications of the

simple 1D Fourier transform or its inverse, instead of by one application of

the more complex 2D Fourier transform.

• That is, first transform along each row, and then transform along each

column, or vice versa.

[email protected]

Page 20: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

20

Translation

• A shift in

f(x, y) = f(x − x0, y − y0)does not affect the magnitude function |F(u, v)|:

• It only affects the phase angle φ(u, v).

• Keep in mind when displaying the magnitude function!

• MATLAB demonstration

[email protected]

Page 21: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

21

Periodicity

• The discrete Fourier transform is periodic:

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

• Why Periodic?

• Only one period is necessary to reconstruct

f(x, y)

[email protected]

Page 22: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

22

Conjugate Symmetry

[email protected]

Page 23: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

23

Rotation Dependency

• Rotating f(x, y) by an angle α rotates F(u, v) by the same angle.

• Similarly, rotating F(u, v) rotates f(x, y) by the same angle.

[email protected]

Page 24: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

24

Convolution theorem

• Convolution in the spatial domain

⇐⇒

multiplication in frequency domain

• f(x, y) ∗ g(x, y) = F−1{F(u, v) · G(u, v)}

and vice versa

• F(u, v) ∗ G(u, v) = F{f(x, y) · g(x, y)}

[email protected]

Page 25: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

25

Examples

[email protected]

Page 26: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

26

Examples

[email protected]

Page 27: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

27

Enhancement in frequency domain

• Steps in filtering in the frequency domain

(simplified):

1. Compute the Fourier-transform of the image

to be enhanced.

2. Multiply the result by a frequency filter.

3. Compute the inverse Fourier-transform to

produce the enhanced image.

[email protected]

Page 28: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

28

Enhancement in frequency domain

• When filtering images by a mask, convolution in the spatial

domain is used.

• We can get the frequency filter by computing the Fourier

transform of the spatial filter (the mask).

• Then, filtering by multiplying the Fourier transformed image

and the frequency filter is equal to filtering by convolution in

spatial domain.

[email protected]

Page 29: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

29

Smoothing frequency-domain filters

• High frequencies are attenuated; noise and

edges are blurred.

• Ideal lowpass filter: ILPF

• Butterworth lowpass filter: BLPF

• Gaussian lowpass filter: GLPF

[email protected]

Page 30: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

30

Ideal lowpass filtering

• Only values of F(u, v) near (u, v) = (0, 0)

remains after filtering Only low

frequencies remains after filtering

[email protected]

Page 31: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

31

Gaussian lowpass filtering

The frequency filter must have the same size as the original image,

this is achieved by “filling up” the frequency filter with zeros.

[email protected]

Page 32: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

32

Gaussian lowpass filtering

[email protected]

Page 33: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

33

Sharpening frequency-domain

filters

• Low frequencies are attenuated; noise and

edges are enhanced.

• The reverse operation of lowpass filters.

• Ideal highpass filter: IHPF

• Butterworth highpass filter: BHPF

• Gaussian highpass filter: GHPF

• The Laplacian in the frequency domain

[email protected]

Page 34: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

34

Ideal highpass filtering

• Only values of F(u, v) far from (u, v) = (0, 0) remains after filtering

Only high frequencies remains after filtering.

[email protected]

Page 35: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

35

Gaussian highpass filter

• By taking one minus the Gaussian lowpass filter

(GLPF),

• the Gaussian highpass filter (GHPF) is achieved.

[email protected]

Page 36: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

36

Gaussian highpass filter

[email protected]

Page 37: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

37

Laplacian in frequency domain

[email protected]

Page 38: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

38

Laplacian in frequency domain

[email protected]

Page 39: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

39

Decimation-free directional filter

bank(DDFB)

[email protected]

Page 40: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

40

DDFB

[email protected]

Page 41: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

41

DDFB

[email protected]

Page 42: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

42

DDFB

[email protected]

Page 43: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

43

Directional analysis

[email protected]

Page 44: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

44

Directional analysis

[email protected]

Page 45: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

45

Directional analysis

[email protected]

Page 46: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

46

DDFB

[email protected]

Page 47: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

47

Directional analysis

[email protected]

Page 48: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

48

Directional analysis

[email protected]

Page 49: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

49

Directional analysis

[email protected]

Page 50: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

50

Directional analysis

[email protected]

Page 51: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

51

Directional analysis

[email protected]

Page 52: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

52

Directional analysis

[email protected]

Page 53: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

53

Directional analysis

[email protected]

Page 54: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

54

Directional analysis

[email protected]

Page 55: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

55

Directional analysis

[email protected]

Page 56: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

56

Directional analysis

[email protected]

Page 57: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

57

Design of DDFB

[email protected]

Page 58: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

58

DDFB

• Divides an Image into its directional

components

• It is common practice to divide an image into

eight directional components. But it is mostly

dependent on the image information

• Noise is omni-directional

[email protected]

Page 59: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

59

Image enhancement with DDFB

[email protected]

Page 60: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

60

Image enhancement with DDFB

[email protected]

Page 61: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

61

Image enhancement with DDFB

[email protected]

Page 62: Transforms and Frequency Filtering - CBAkhalid/TODB/frequency_domain_filteringTODB...• When filtering images by a mask, convolution in the spatial domain is used. • We can get

62

Next lecture

• Image Restoration

• Time1315hrs

• Date: 28/10/09

[email protected]