Upload
others
View
6
Download
0
Embed Size (px)
Citation preview
Transforms and
Frequency Filtering
Khalid NiaziCentre for Image Analysis
Swedish University of Agricultural Sciences
Uppsala University
2
Reading Instructions
• Chapter 4: Image Enhancement in the
Frequency Domain
• Book: Digital Image Processing by Gonzalez &
Woods, Third Edition, 2007
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
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.
5
Frequency domain representation
• We need to know
– Frequency
– Sinusoids
– Euler’s formula
– …
6
Frequency domain representation
• Frequency: Cycles per second
• Sinusoids: Common name for Cosine and Sine
• Euler's formula
7
Frequency domain representation
• Using Euler’s formula one can write a Sinusoid
as,
0
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
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
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
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
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
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.
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)|)
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.
18
Properties of the Fourier transform
• Separability
• Translation
• Periodicity
• Conjugate Symmetry
• Rotation
• Convolution
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.
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
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)
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.
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)}
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.
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.
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
30
Ideal lowpass filtering
• Only values of F(u, v) near (u, v) = (0, 0)
remains after filtering Only low
frequencies remains after filtering
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.
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
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.
35
Gaussian highpass filter
• By taking one minus the Gaussian lowpass filter
(GLPF),
• the Gaussian highpass filter (GHPF) is achieved.
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