Lecture 12: Image Processing and 2D TransformsLecture 12: Image Processing and 2D Transforms Harvey...
Transcript of Lecture 12: Image Processing and 2D TransformsLecture 12: Image Processing and 2D Transforms Harvey...
Lecture 12: Image Processing and 2DTransforms
Harvey RhodyChester F. Carlson Center for Imaging Science
Rochester Institute of [email protected]
October 18, 2005
AbstractThe Fourier transform provides information about the global
frequency-domain characteristics of an image. The Fourier descriptioncan be computed using discrete techniques, which are natural fordigital images. Here we focus on the relationship between the spatialand frequency domains.
DIP Lecture 12
2D Fourier TransformLet f(x, y) be a 2D function that may have infinite support. The 2D Fouriertransform pair is defined
F(u, v) =∫ ∞
−∞
∫ ∞
−∞f(x, y)e−i2π(ux+vy)dxdy
f(x, y) =∫ ∞
−∞
∫ ∞
−∞F(u, v)ei2π(ux+vy)dudv
We are interested in transforms related to images, which are defined on afinite support. If an image has width A and height B with the origin at thecenter, then
F(u, v) =∫ A/2
−A/2
∫ B/2
−B/2
f(x, y)e−i2π(ux+vy)dxdy
where f(x, y) represents the image brightness at point (x, y).
This expression assumes that f(x, y) is extended with f(x, y) = 0 outsidethe image frame.
DIP Lecture 12 1
Periodic Extension
If it is assumed that f(x, y) is extended periodically outside the image framethen we can use a Fourier series.
f(x, y) =∞∑
u=−∞
∞∑v=−∞
F (u, v)ei2π(ux/A+vy/B)
Note the following:
1. (u, v) take on integer values.
2. (x, y) take on a continuum of values.
3. f(x, y) is periodic with
f(x + nA, y + mB) = f(x, y)
for any integers (n, m).
DIP Lecture 12 2
Fourier Series Coefficient
Multiply both sides of the Fourier series expression by e−i2π(ax/A+by/B)andintegrate over the image frame.
∫ A/2
−A/2
∫ B/2
−B/2
f(x, y)e−i2π(axA +by
B )dxdy
=∞∑
u=−∞
∞∑v=−∞
F (u, v)∫ A/2
−A/2
∫ B/2
−B/2
ei2π
�x(u−a)
A +y(v−b)
B
�dxdy
= ABF (a, b)
DIP Lecture 12 3
Fourier Series Coefficient (cont)
Hence, the Fourier series coefficient is
F (a, b) =1
AB
∫ A/2
−A/2
∫ B/2
−B/2
f(x, y)e−i2π(axA +by
B )dxdy
=1
ABF
(a
A,
b
B
)for integer (a, b)
DIP Lecture 12 4
Bandwidth Limited Approximation
Suppose that F(u, v) ≈ 0 outside a region
Suv = {u, v| −Wu ≤ u ≤ Wu,−Wv ≤ v ≤ Wv}
Then it can be extended periodically outside Suv and expressed as a Fourierseries over the spatial domain.
F(u, v) =∞∑
x=−∞
∞∑y=−∞
f(x, y)e−i2π( ux2Wu
+ vy2Wv
)
Note that:
1. (x, y) take on integer values.
2. (u, v) take on a continuum of values.
3. F(u, v) is periodic with
F(u + 2nWu, v + 2mWv) = F(u, v) for any integers (n, m)
DIP Lecture 12 5
Fourier Series Coefficient
We can use an analysis similar to the above to find the value of f(s, t) atinteger values of (s, t). We find
f(s, t) =1
4WuWvf
(s
2Wu,
t
2Wv
)
The image plane is sampled on a grid with spacing(
12Wu
, 12Wv
). The
number of samples that are needed in each dimension are
N = 2AWu
M = 2BWv
DIP Lecture 12 6
Discrete Fourier Transform
We have already seen that
F (a, b) =1
ABF
(a
A,
b
B
)All of the information we need is provided by samples of F(u, v) on a gridwith spacing
(1A, 1
B
). The number of points need are
N = 2AWu
M = 2BWv
We need the same number of values to describe the image, whether thevalues are from the spatial domain or the frequency domain.
The samples of F are complex numbers, but the information is the samebecause of symmetries.
DIP Lecture 12 7
Discrete Fourier Transform
We can now construct the DFT pair by substituting into
F(u, v) =∞∑
x=−∞
∞∑y=−∞
f(x, y)e−i2π( ux2Wu
+ vy2Wv
)
ABF (a, b) = F(
a
A,
b
B
)=
N−1∑x=0
M−1∑y=0
14WuWv
f(x
2Wu,
y
2Wv)e−i2π
�ax
2AWu+ by
2BWv
�
F (a, b) =1
MN
N−1∑x=0
M−1∑y=0
f(x
2Wu,
y
2Wv)e−i2π
�axN +by
M
�
DIP Lecture 12 8
Discrete Fourier Transform
It is conventional to replace f with f without keeping track of the extra4WuWv factor. We’ll follow convention and worry about the scaling whenwe do numerical computations. We’ll also replace (a, b) by (u, v). Thisproduces the transform pair
F (u, v) =1
MN
N−1∑x=0
M−1∑y=0
f(x, y)e−i2π(uxN +vy
M )
f(x, y) =N−1∑u=0
M−1∑v=0
F (u, v)ei2π(uxN +vy
M )
It is often the case that the origin of an array that represents F (u, v) is at acorner. This does no harm because F (u, v) is periodic with period (N,M),but one must pay attention.
DIP Lecture 12 9
Example: G&W Figure 4.3
40× 20 Rectangle |F (u, v)| Row and Column Profiles
DIP Lecture 12 10
Example: G&W Figure 4.6
Original Spectrum
Image with F (0, 0) = 0 Spectrum contours
DIP Lecture 12 11
Fourier Image Components
An image, represented by f(x, y) is the sum of a set of component images
f(x, y;u, v) = F (u, v)ei2π(uxN +vy
M )
We can write the image as
f(x, y) =N−1∑u=0
M−1∑v=0
f(x, y;u, v)
It is important to understand the nature of the image components.
DIP Lecture 12 12
What is f(x, y;u, v)?
1. F (u, v) is just a complex number. There are MN of them–one for each(u, v) combination.
2. F (u, v) = A(u, v)eiθ(u,v) where A(u, v) is the size and θ(u, v) is theangle of the complex number.
3. It is a compact way to write
f(x, y;u, v) = F (u, v)ei2π(uxN +vy
M )
= A(u, v) cos[2π
(ux
N+
vy
M
)+ θ(u, v)
]+ iA(u, v) sin
[2π
(ux
N+
vy
M
)+ θ(u, v)
]
DIP Lecture 12 13
What is F (u, v)ei2π(uxN +vy
M )?
4. If f(x, y) is real then F (u, v)=F ∗(N − u, M − v). This means thatA(N − u, M − v) = A(u, v) and θ(N − u, M − v) = −θ(u, v).
5. We can combine the (u, v) and (N − u, M − v) terms as
F (u, v)ei2π(uxN +vy
M ) + F (N − u, M − v)ei2π�
(N−u)xN +
(M−v)yM
�
= 2A(u, v) cos[2π
(ux
N+
vy
M
)+ θ(u, v)
]6. Similarly, for real f(x, y), the (u, M − v) and (N − u, v) terms can be
combined since F (u, M − v) = F ∗(N − u, v)
F (u, M − v)ei2π�
uxN +
(M−v)yM
�+ F (N − u, v)ei2π
�(N−u)x
N +vyM
�
= 2A(u, M − v) cos[2π
(ux
N− vy
M
)+ θ(u, M − v)
]
DIP Lecture 12 14
The long version
f(x, y) = A[0, 0] +N/2−1∑
u=1
2A(u, 0) cos[2π
ux
N+ θ(u, 0)
]
+M/2−1∑
v=1
2A(0, v) cos[2π
vy
M+ θ(0, v)
]
+N/2−1∑
u=1
M/2−1∑v=1
2A(u, v) cos[2π
(ux
N+
vy
M
)+ θ(u, v)
]
+N/2−1∑
u=1
M/2−1∑v=1
2A(u, M − v) cos[2π
(ux
N− vy
M
)+ θ(u, M − v)
]
Examples of some of the components are shown on the next slide.
DIP Lecture 12 15
Some Components
u = 1 v = 0 u = 0 v = 1 u = 1 v = 2
u = 2 v = −1 u = 3 v = 5 u = 5 v = 3
DIP Lecture 12 16
Filtering
Let H(u, v) be the system function of a linear shift-invariant filter.
Let f(x, y) be the input image and g(x, y) be the output image.
The LSI filter operates independently on each of the exponential functionimage components.
f(x, y;u, v) = F (u, v)ei2π(xuN +yv
M )
The corresponding component of the output image is
g(x, y;u, v) = H(u, v)f(x, y;u, v)
= H(u, v)F (u, v)ei2π(xuN +yv
M )
The complete output image is
g(x, y) =N−1∑u=0
M−1∑v=0
g(x, y;u, v)
DIP Lecture 12 17
Filtering
The output image g(x, y) has a DFT
G(u, v) =1
MN
N−1∑x=0
M−1∑y=0
g(x, y)e−i2π(uxN +vy
M )
g(x, y) =N−1∑u=0
M−1∑v=0
G(u, v)ei2π(uxN +vy
M )
whereG(u, v) = H(u, v)F (u, v)
The filter operates by changing the magnitude and phase of each (u, v)component by multiplying F (u, v) by H(u, v).
DIP Lecture 12 18
Filter Construction
An image can be processed by multiplication with a filter function
G(u, v) = F (u, v)H(u, v)
Butterworth lowpass filter:
H(u, v) =1
1 +(
u2+v2
D20
)n
Butterworth filter of order n = 2
DIP Lecture 12 19
Constructing a Filter Array
Given an image of size N ×M , we need to construct a filter of the samesize. For a Butterworth LP of order p do the following:
x=Indgen(N)-N/2 ;x-axis (centered)y=Indgen(M)-M/2 ;y-axis (centeredu=x#replicate(1,M) ;The u-coordinate planev=y##replicate(1,N) ;The v-coordinate planeD=(u^2+v^2)/D0^2H=1/(1+D^p)surface,H,u,v
DIP Lecture 12 20
Filtering with LPF
Original After LPF
Spectrum |HLP (u, v)|
DIP Lecture 12 21
HPF Characteristic
A highpass filter can be constructed from a lowpass filter by subtraction.
HHP (u, v) = HLP (0, 0)−HLP (u, v)
For the Butterworth filter
HHP (u, v) = 1− 1
1 +(
u2+v2
D20
)n
=
(u2+v2
D20
)n
1 +(
u2+v2
D20
)n
DIP Lecture 12 22
Filtering with HPF
Original After HPF
Spectrum |HHP (u, v)|
DIP Lecture 12 23
Filter Construction;Construct coordinate arrays of size NxMu=(Findgen(N)-N/2)#Replicate(1,M)v=(Findgen(M)-M/2)##Replicate(1,N);Construct a lowpass filterD0=30LPF=(u^2+v^2) LT D0^2;Show the filter response functionWindow,/free,xsize=300,ysize=300Shade Surf,LPF,u,v
DIP Lecture 12 24
Image FilteringA=Read Image(‘restest.jpg’)Sa=Size(A,/dimensions)N=Sa[0] & M=Sa[1]Window,/free,xsize=N,ysize=MTV,AAF=FFT(A)AFS=Shift(AF,N/2,M/2)AFSH=LPF*AFSA2=Abs(FFT(AFSH,/Inverse))Window,/free,xsize=N,ysize=MTVSCL,A2
DIP Lecture 12 25