Processing Lectures 5 & 6

Mahmood (Mo) Azimi, Professor Colorado State University Fort Collins, Co 80523 email : [email protected]

Each time you have to click on this icon

wherever it appears to load the next sound file

To advance click enter or page down to go back use page up 1. Parseval’s Theorem and Inner Product Preservation Another important property of FT is that the inner product of two functions is equal to the inner product of their FT’s. ZZ ∞ x(v, u)y∗(u, v)dudv −∞ ZZ ∞ 1 ∗ = 2 X(ω1, ω2)Y (ω1, ω2)dω1dω2 4π −∞ where ∗ stands for complex conjugate operation. When x = y we obtain the well-known Parseval energy conservation formula i.e. ZZ ∞ ZZ ∞ 2 1 2 |x(u, v)| dudv = 2 |X(ω1, ω2)| dω1dω2 −∞ 4π −∞ i.e. the total energy in the function is the same as in its FT. 2. Frequency Response and Eigenfunctions of 2-D LSI Systems An eigen-function of a system is defined as an input function

To advance click enter or page down to go back use page up 1 that is reproduced at the output with a possible change in the amplitude. For an LSI system eigen-functions are given by f(u, v) = exp(jω1u + jω2v)

Using the 2-D integral ZZ ∞ 0 0 0 0 0 0 g(u, v) = h(u − u , v − v ) exp[jω1u + jω2v ]du dv −∞ change u˜ = u − u0, v˜ = v − v0, then g(u, v) = H(ω1, ω2) exp[jω1u + jω2v] where ZZ ∞ H(ω1, ω2) = h(˜u, v˜) exp[jω1u˜ + jω2v˜]dud˜ v˜ −∞ = F{h(u, v)}

To advance click enter or page down to go back use page up 2 is the frequency response of the 2-D system. The output is a complex exponential function with the same frequency as the input but its amplitude and phase are changed by the complex gain H(ω1, ω2) of the 2-D system. Example: Determine the frequency response of a 2-D system whose impulse response is

 1 |u| ≤ X, |v| ≤ Y h(u, v) = 0 elsewhere

Find H(ω1, ω2).

∞ ZZ 0 0 0 0 −j(ω1u +ω2v ) 0 0 H(ω1, ω2) = h(u , v )e du dv −∞

To advance click enter or page down to go back use page up 3 X Y Z Z 0 0 = e−j(ω1u +ω2v )du0dv0 −X −Y X ! Y ! Z 0 0 Z 0 = e−jω1u du e−jω2v dv0 −X −Y ejω1X − e−jω1X ejω2Y − e−jω2Y = ( )( ) jω1 jω2 sin ω X sin ω Y = 2X( 1 )2Y ( 2 ) ω1X ω2Y = 4XY sinc(ω1X)sinc(ω2Y )

See Figure 4.3 in your textbook for the plot of 2D Sinc function. Any interesting observation?

To advance click enter or page down to go back use page up 4 Image Sampling and Quantization The most basic requirement for processing of images is that the images must be available in digital form i.e. arrays of integer numbers. For the given image is sampled on a discrete grid and each sample or is quantized to an integer value representing a gray level. The digitized image can then be processed by the computer.

To advance click enter or page down to go back use page up 5 2-D Sampling Theorem Definition: An image x(u, v) is called ”bandlimited” if its FT X(ω1, ω2) is zero outside a bounded region in the frequency plane i.e.

X(ω1, ω2) = 0 |ω1| > ω10, |ω2| > ω20

ω10, ω20: Bandlimits of the image. If the spectrum is circularly 4 symmetric then the single spatial frequency [ω0 = ω10 = ω20] is the bandwidth.

To advance click enter or page down to go back use page up 6 Sampling Vs. Replication The FT of a sampled image is a scaled, periodic replication of the FT of the original image. To show this result, we sample x(u, v) using and ideal image sampling function, sa(u, v) that is defined as ∞ ∞ 4 X X sa(u, v; ∆u, ∆v) = δ(u − m∆u, v − n∆v) m=−∞ n=−∞ with the “sampling intervals” ∆u, ∆v. The sampled image is

xs(u, v) = x(u, v)sa(u, v; ∆u, ∆v) ∞ X X = x(m∆u, n∆v)δ(u − m∆u, v − n∆v) m,n=−∞

It can be shown that the FT of the sampling function with spacing

To advance click enter or page down to go back use page up 7 2π 2π ∆u, ∆v is another sampling function with spacing ∆u, ∆v. Then, using the convolution in we get

∞ 1 X X 2πk 2πl X (ω , ω ) = X(ω − , ω − ) s 1 2 ∆u∆v 1 ∆u 2 ∆v k,l=−∞

Let us define discrete frequency variables (i.e. in discrete ∆ ∆ domain) Ω1=ω1∆u,Ω2=ω2∆v, then we get 2-D Discrete Space Fourier Transform (DSFT),

∞ 1 X X Ω1 − 2πk Ω2 − 2πl X (Ω , Ω ) = X( , ) s 1 2 ∆u∆v ∆u ∆v k,l=−∞

This result shows sampling in the spatial domain causes periodicity in the frequency domain (See Figure).

To advance click enter or page down to go back use page up 8 ω 2

ωvs/2

ωvs R1 ωvs-ω20

ωus-ω10

ω20 ω −ωus ωus 1 −ω10 ω10

−ω20 R R 2 ωus/2

−ωvs

To advance click enter or page down to go back use page up 9 ∆ 2π ∆ 2π Let ωus = ∆u and ωvs = ∆v (i.e. sampling frequencies), then alternatively

∞ 1 X X X (ω , ω ) = ω ω X(ω − kω , ω − lω ) s 1 2 4π2 us vs 1 us 2 vs k,l=−∞

As can be seen from the Figure, for no overlapping between the replica the lower bounds on the sampling frequencies are 2ω10 and 2ω20. These frequencies are referred to as ”Nyquist frequencies”. Their reciprocals are called ”Nyquist intervals”. The sampling frequency must be equal to or greater than twice the frequency associated with the finest detail in the image (edges).

To advance click enter or page down to go back use page up 10 Reconstruction If the sampling frequencies ωus and ωvs are greater than twice of the bandlimits i.e. ωus ≥ 2ω10, ωvs ≥ 2ω20 then X(ω1, ω2) can be recovered from Xs(ω1, ω2) by a 2-D ideal low-pass filter (interpolation filter) with frequency response

 ∆u∆v ω , ω ∈ R H(ω , ω ) = 1 2 1 2 0 otherwise

where R is any region whose boundary aR is contained within the region between R1 and R2 as shown in the Figure. Then

X˜(ω1, ω2) = H(ω1, ω2)Xs(ω1, ω2) = X(ω1, ω2)

i.e. exact reconstruction.

To advance click enter or page down to go back use page up 11 A typical choice for R is a rectangular region, e.g. R =  ωus ωus  ωvs ωvs − 2 , 2 × − 2 , 2 for which the impulse response is the ideal 2-D interpolation function i.e.

h(u, v) = Sinc(uωus)sinc(vωvs)

That is, X(ω1, ω2) = H(ω1, ω2) · Xs(ω1, ω2), gives

x˜(u, v) = h(u, v) ∗ ∗xs(u, v) ∞ X X = x(m∆u, n∆v)sinc(ωus(u − m∆u)) m,n=−∞

sinc(ωvs(v − n∆v))

To advance click enter or page down to go back use page up 12 Remarks

1. The above equation is an infinite order interpolation that reconstructs the continuous function x(u, v) from its samples x(m∆u, n∆v). 2. For a rectangular passband with size W1 × W2, the impulse response of the interpolation filter is h(u, v) = sinc(uW1)sinc(vW2). and Effects If the sampling frequencies are below the Nyquist rates i.e. ωus < 2ω10 and ωvs < 2ω20, then the periodic replications of X(ω1, ω2) will overlap, resulting in a distorted spectrum Xs(ω1, ω2) from which X(ω1, ω2) cannot be recovered. The frequencies above ωus ωvs half the sampling frequencies, that is, above 2 , 2 are called

To advance click enter or page down to go back use page up 13 the ”fold-over frequencies”. This overlapping causes some of the high frequencies (or fold-over frequencies) in the original image to ωus ωvs appear as low frequencies (below 2 , 2 ) in the sampled image. This phenomenon is called ”Aliasing”. Aliasing cannot be removed by post filtering but can be avoided by pre low pass filtering the image so that its bandlimits are less than one-half of the sampling frequencies.

In images aliasing causes edge smearing and loss of details. The spectrum of an undersampled image can be written as

1 X (ω , ω ) = [X(ω , ω ) + E(ω , ω )] s 1 2 ∆u∆v 1 2 1 2

To advance click enter or page down to go back use page up 14 where

∞ X X E(ω1, ω2) = X(ω1 − kωus, ω2 − lωvs) k, l = −∞ (k, l) 6= (0, 0)

After the filtering with a 2-D LPF

 ∆u∆v |ω | ≤ ωus, |ω | ≤ ωvs H(ω , ω ) = 1 2 2 2 1 2 0 otherwise

we get X˜(ω1, ω2) = H(ω1, ω2)Xs(ω1, ω2). In the spatial domain, we get

x˜(u, v) = x(u, v) + e(u, v)

To advance click enter or page down to go back use page up 15 where

ωus ωvs 1 Z 2 Z 2 e(u, v) = 2 E(ω1, ω2) exp[j(ω1u + ω2v)]dω1dω2 4π ωus ωvs − 2 − 2

represents the aliasing error artifact in the reconstructed image after the filtering. Example: An image described by the function

x(u, v) = 2 cos (3u + 4v)

is sampled at ∆u = ∆v = 0.4π. Find the reconstructed image x˜(u, v).

To advance click enter or page down to go back use page up 16 Expand

cos(3u + 4v) = {ej(3u+4v) + e−j(3u+4v)}/2

jω t and use the property F{e 0 } = 2πδ(ω − ω0), to find the 2D spectrum of x(u, v) as

2 X(ω1, ω2) = (2π) [δ(ω1 − 3, ω2 − 4) + δ(ω1 + 3, ω2 + 4)]

which is bandlimited since X(ω1, ω2) = 0 for |ω1| > 3,|ω2| > 4 2π 2π Thus ω10 = 3 and ω20 = 4. Also ωus = ∆u = 5 and ωvs = ∆v = 5 which are less than the Nyquist frequencies 2ω10 = 6 and 2ω20 = 8. Thus aliasing is inevitable. The spectrum of the sampled image is

∞ 1 X X 2π 2π X (ω , ω ) = X(ω − k, ω − l) s 1 2 ∆u∆v 1 ∆u 2 ∆v k,l=−∞

To advance click enter or page down to go back use page up 17 ∞ X X = 25 [δ(ω1 − 3 − 5k, ω2 − 4 − 5l) k,l=−∞

+δ(ω1 + 3 − 5k, ω2 + 4 − 5l)]

The LPF has a rectangular passband with cutoff frequencies at half the Nyquist frequencies i.e.

 (0 · 4π)2 |ω | ≤ 2.5, |ω | ≤ 2.5 H(ω , ω ) = 1 2 1 2 0 otherwise

After filtering we obtain

2 X˜(ω1, ω2) = (2π) [δ(ω1 − 2, ω2 − 1) + δ(ω1 + 2, ω2 + 1)]

To advance click enter or page down to go back use page up 18 which gives

x˜(u, v) = 2 cos (2u + v)

Remarks 1. Any frequency component in the original image which is above ωus ωvs [ 2 , 2 ] by (∆ωu, ∆ωv) is reproduced (or aliased) as a lower ωus ωvs frequency component at [ 2 − ∆ωu, 2 − ∆ωv]. In the previous ωus example, the frequency components 3,4 are above 2 = 2.5 and ωvs 2 = 2.5 by ∆ωu = 0.5 and ∆ωv = 1.5, respectively. Thus, these frequencies will be aliased at 2.5 − 0.5 and 2.5 − 1.5, which give x˜(u, v) = 2 cos (2u + v). 2. Images corrupted by additive wideband noise have spectra with long tails. Thus, sampling based upon the bandlimits of the

To advance click enter or page down to go back use page up 19 original image will result in aliasing effects as the tail of the spectrum will fold-over into the bandlimits of the image. This obviously causes additional noise in the reconstructed image. To prevent this problem the image must be prefiltered prior to sampling.

To advance click enter or page down to go back use page up 20