We can therefore directly design a transfer function Hu,v and implement the enhancement in the frequency domain as follows: Gu,v = Hu,v*Fu,v 3 Enhanced Image Transfer Function Give
Trang 1 Prof Duong Anh Duc
Trang 2 The concept of filtering is easier to visualize in the frequency domain Therefore, enhancement of image f(m,n) can be done in the frequency domain, based on its DFT F(u,v)
This is particularly useful, if the spatial extent of the point-spread
sequence h(m,n) is large In this case, the convolution
g(m,n) = h(m,n)*f(m,n)
may be computationally unattractive
2
Enhanced Image
PSS
Given Image
Trang 3 We can therefore directly design a transfer function H(u,v) and
implement the enhancement in the frequency domain as follows:
G(u,v) = H(u,v)*F(u,v)
3
Enhanced Image
Transfer Function
Given Image
Trang 4 Given a 1-d sequence s[k], k = {…,-1,0,1,2,…,}
Fourier transform
Fourier transform is periodic with 2
Inverse Fourier transform
4
Trang 5 How is the Fourier transform of a sequence s[k] related to the Fourier transform of the continuous signal
Continuous-time Fourier transform
5
Trang 6 Given a 2-d matrix of image samples
s[m,n], m,n Z2
Fourier transform
Fourier transform is 2-periodic both in x and y
Inverse Fourier transform
6
Trang 7 How is the Fourier transform of a sequence s[m,n] related to the
Fourier transform of the continuous signal
Continuous-space 2D Fourier transform
7
Trang 8|F(u,v)| displayed as image
f(x,y)
Trang 99
|F(u,v)| displayed in 3-D
Trang 1010 Image Magnitude Spectrum
Trang 1111 Image Magnitude Spectrum
Trang 1212 Image Magnitude Spectrum
Trang 13 As the size of the box increases in spatial domain, the corresponding
“size” in the frequency domain decreases
13
Trang 14|F(u,v)|
f(x,y)
Trang 1515
Trang 1616
|G(u,v)|
g(x,y)
Trang 1717
Trang 18 Image formed from magnitude
spectrum of Rice and phase
spectrum of Camera man
18
Trang 19 Image formed from magnitude
spectrum of Camera man and
phase spectrum of Rice
19
Trang 20 For discrete images of finite extent, the analogous Fourier transform is the DFT
We will first study this for the 1-D case, which is easier to visualize
Suppose { f(0), f(1), …, f(N – 1)} is a sequence/ vector/1-D image
of length N Its N-point DFT is defined as
Inverse DFT (note the normalization):
20
Trang 21 Example: Let f(n) = {1, -1 ,2,3 } (Note that N=4)
21
Trang 22 F(u) is complex even though f(n) is real This is typical
Implementing the DFT directly requires O(N2) computations, where N
is the length of the sequence
There is a much more efficient implementation of the DFT using the
Fast Fourier Transform (FFT) algorithm This is not a new transform (as the name suggests) but just an efficient algorithm to compute the DFT
22
Trang 23 The FFT works best when N = 2m (or is the power of some integer
base/radix) The radix-2 algorithm is most commonly used
The computational complexity of the radix-2 FFT algorithm is Nlog(N)
adds and ½Nlog(N) multiplies So it is an Nlog(N) algorithm
In MATLAB, the command fft implements this algorithm (for 1-D
case)
23
Trang 24 The Fourier transform is suitable for continuous-domain images, which maybe of infinite extent
For discrete images of finite extent, the analogous Fourier transform is the 2-D DFT
24
Trang 25 Suppose f(m,n), m = 0,1,2,…M – 1, n = 0,1,2,…N – 1, is a discrete
N M image Its 2-D DFT F(u,v) is defined as:
Inverse DFT is defined as:
25
Trang 26 For discrete images of finite extent, the analogous Fourier transform is the 2-D DFT
Note about normalization: The normalization by MN is different than that in text We will use the one above since it is more widely used The Matlab function fft2 implements the DFT as defined above
26
Trang 27 Most often we have M=N (square image) and in that case, we define a unitary DFT as follows:
We will refer to the above as just DFT (drop unitary) for simplicity
27
Trang 29In matlab, if f and h are matrices representing two images,
conv2(f, h) gives the 2D-convolution of images f and h
Trang 30 Linearity (Distributivity and Scaling): This holds inboth discrete and
continuous-domains
o DFT of the sum of two images is the sum of their individual DFTs
o DFT of a scaled image is the DFT of the original image scaled by the same factor
30
Trang 31 Spatial scaling (only for continuous-domain):
o If a, b > 1, image “shrinks” and the spectrum “expands.”
31
Trang 32 Periodicity (only for discrete case): The DFT and its inverse are
periodic (in both the dimensions), with period N
F(u,v) = F(u+N,v) = F(u,v+N) = F(u+N,v+N)
o Similarly,
is also N-periodic in m and n
32
Trang 33 Separability (both continuous and discrete): Decomposition of 2D DFT into 1D DFTs
33
Trang 34o Similarly,
34
Trang 35 Convolution: In continuous-space, Fourier transform of the convolution
is the product of the Four transforms
F[f(x,y)*h(x,y)] = F(u,v) H(u,v)
Trang 36o In other words, output spectrum G(u,v) is the product of the input spectrum F(u,v) and the transfer function H(u,v)
o So the FT can be used as a computational tool to simplify the
convolution operation
36
Trang 37 Correlation: In continuous-space, correlation between two images
f(x,y) and h(x,y) is defined as:
Therefore,
37
Trang 38 rff(x,y) is usually called the auto-correlation of image f(x,y) (with
itself) and rff(x,y) is called the crosscorrelation between f(x,y) and
h(x,y)
Roughly speaking, rfh(x,y) measures the degree of similarity between images f(x,y) and h(x,y) Large values of rfh(x,y) would indicate that the images are very similar
38
Trang 39 This is usually used in template matching, where h(x,y) is a template shape whose presence we want to detect in the image f(x,y)
Locations where rfh(x,y) is high (peaks of the crosscorrelation
function) are most likely to be the location of shape h(x,y) in image
f(x,y)
39
Trang 40 Convolution property for discrete images: Suppose
Trang 41So if we want a convolution property for discrete images - something like
g(m,n) = f(m,n)*h(m,n)
we need to have G(u, v) to be of size (M+K–1)(N+L–1) (since
Therefore, we should require that F(u, v) and H(u, v) also have the same dimension, i.e (M+K–1)(N+L–1)
41
Trang 42So we zero-pad the images f(m, n), h(m, n), so that they are of size
(M+K–1 )(N+L–1) Let fe(m,n) and he(m,n) be the zero-padded (or extended images)
Take their 2D-DFTs to obtain F(u, v) and H(u, v), each of size
(M+K–1)(N+L– 1) Then
Similar comments hold for correlation of discrete images as well
42
Trang 43 Translation: (discrete and continuous case):
Note that
but different phase spectrum
Similarly,
43
Trang 44 Conjugate Symmetry: If f(m, n) is real, then F(u, v) is conjugate
symmetric, i.e
Therefore, we usually display F(u–N/2,v–N/2), instead of F(u, v),
since it is easier to visualize the symmetry of the spectrum in this case
This is done in Matlab using the fftshift command
44
Trang 45 Multiplication: (In continuous-domain) This is the dual of the
convolution property Multiplication of two images corresponds to
convolving their spectra
F[f(x,y)h(x,y)] = F(u,v) H(u,v)
45
Trang 46f(m,n)
Trang 4747
|F(u–N/2,v–N/2)|
|F(u,v)|
Trang 48 Average value: The average pixel value in an image:
Notice that (substitute u = v = 0 in the definition):
48
Trang 49 Differentiation: (Only in continuous-domain): Derivatives are normally used for detecting edged in an image An edge is the boundary of an object and denotes an abrupt change in grayvalue Hence it is a region with high value of derivative
49
Trang 53 Edges and sharp transitions in grayvalues in an image contribute
significantly to high-frequency content of its Fourier transform
Regions of relatively uniform grayvalues in an image contribute to frequency content of its Fourier transform
low- Hence, an image can be smoothed in the Frequency domain by
attenuating the high-frequency content of its Fourier transform
This would be a lowpass filter!
53
Trang 55 For simplicity, we will consider only those filters that are real and
radially symmetric
An ideal lowpass filter with cutoff frequency r0:
55
Trang 56 Note that the origin (0, 0) is at the center and not the corner of the
image (recall the “fftshift” operation)
The abrupt transition from 1 to 0 of the transfer function H(u,v) cannot
be realized in practice, using electronic components However, it can
be simulated on a computer
56 Ideal LPF with r0 = 57
Trang 5757 Ideal LPF with r0 = 57
Original Image
Trang 5858 Ideal LPF with r0 = 26
Ideal LPF with r0= 36
Trang 59 Notice the severe ringing effect in the blurred images, which is a
characteristic of ideal filters It is due to the discontinuity in the filter
transfer function
59
Trang 60 The cutoff frequency r0 of the ideal LPF determines the amount of
frequency components passed by the filter
Smaller the value of r0, more the number of image components
eliminated by the filter
In general, the value of r0 is chosen such that most components of
interest are passed through, while most components not of interest are eliminated
Usually, this is a set of conflicting requirements We will see some
details of this is image restoration
A useful way to establish a set of standard cut-off frequencies is to
compute circles which enclose a specified fraction of the total image power
60
Trang 61 Suppose
where is the total image power
Consider a circle of radius =r0(a) as a cutoff frequency with respect to
a threshold a such that
We can then fix a threshold a and obtain an appropriate cutoff
frequency r0(a)
61
Trang 62 A two-dimensional Butterworth lowpass filter has transfer function:
n: filter order, r0: cutoff frequency
62
Trang 65 Frequency response does not have a sharp transition as in the ideal LPF
This is more appropriate for image smoothing than the ideal LPF, since this not introduce ringing
65
Trang 66LPF with r0= 18 Original Image
Trang 6767 LPF with r0= 10
LPF with r0= 13
Trang 6868
Image with false contouring
due to insufficient bits used
for quantization
Lowpass filtered version of
previous image
Trang 6969 Original Image Noisy Image
Trang 7070 LPF Image
Trang 71 The form of a Gaussian lowpass filter in two-dimensions is given by
where
is the distance from the origin in the frequency plane
The parameter s measures the spread or dispersion of the Gaussian curve Larger the value of s, larger the cutoff frequency and milder the filtering
When s = D(u, v), the filter is down to 0.607 of its maximum value of
1
71
, v u v u
Trang 7272
Trang 73 Edges and sharp transitions in grayvalues in an image contribute
significantly to high-frequency content of its Fourier transform
Regions of relatively uniform grayvalues in an image contribute to frequency content of its Fourier transform
low- Hence, image sharpening in the Frequency domain can be done by attenuating the low-frequency content of its Fourier transform This
would be a highpass filter!
73
Trang 74 For simplicity, we will consider only those filters that are real and
radially symmetric
An ideal highpass filter with cutoff frequency r0:
74
Trang 75 Note that the origin (0, 0) is at the center and not the corner of the
image (recall the “fftshift” operation)
The abrupt transition from 1 to 0 of the transfer function H(u,v) cannot
be realized in practice, using electronic components However, it can
be simulated on a computer
75 Ideal HPF with r0= 36
Trang 7676 Ideal HPF with r0= 18
Original Image
Trang 7777 Ideal HPF with r0= 26
Ideal HPF with r0= 36
Trang 78 Notice the severe ringing effect in the output images, which is a
characteristic of ideal filters It is due to the discontinuity in the filter
transfer function
78
Trang 79 A two-dimensional Butterworth highpass filter has transfer function:
n: filter order, r0: cutoff frequency
79
Trang 81 Frequency response does not have a sharp transition as in the ideal HPF
This is more appropriate for image sharpening than the ideal HPF,
since this not introduce ringing
81
Trang 82HPF with r0= 47 Original Image
Trang 8383 HPF with r0= 81
HPF with r0= 36
Trang 84 The form of a Gaussian lowpass filter in two-dimensions is given by
where
is the distance from the origin in the frequency plane
The parameter s measures the spread or dispersion of the Gaussian curve Larger the value of s, larger the cutoff frequency and more
severe the filtering
84
, v u v u
2 ,
1 , v e D u v u
Trang 8585