Вы находитесь на странице: 1из 2

Spring 2012

ECE 5273 Homework 5

Dr. Havlicek

1. The images in this problem are all of size 8 × 8. Some of the images are real-valued; in this case, each pixel is a floating point number (use float arrays in C). Some of the images are also complex-valued; in C you must use one float array for the real part and another float array for the imaginary part.

(a)

(b)

(c)

(d)

Let I 1 be defined by

I 1 (i, j) = 1 2 exp 1 2π (u 0 i + v 0 j) ,

√ − 1 2 π ( u 0 i + v 0 j ) , 8

8

where i = COLUMN, j = ROW, u 0 = 2 cycles per image (cpi) is the horizontal frequency, and v 0 = 2 cpi is the vertical frequency. Show the real and imaginary parts of I 1 as gray scale images with 8 bits per pixel (bpp) and full-scale contrast. Compute the DFT I 1 and center it so that the frequency origin is in the middle (this is done automatically by the C function fft2d). Print out the real and imaginary parts of I 1 as 8 × 8 ascii floating point arrays. Whether you use Matlab, C, or some other language, be sure to format the output so that it is easy to read (the columns should line up and the rows should not “line-wrap”).

Let I 2 be defined by

I 2 (i, j) = 1 2 exp 1 2π (u 0 i + v 0 j) .

− √ − 1 2 π ( u 0 i + v 0 j ) .

8

Show the real and imaginary parts of I 2 as 8 bpp gray scale images with full-scale contrast. Compute the centered DFT I 2 and print out the real and imaginary parts of as 8 × 8 ascii floating point arrays.

Let I 3 be defined by I 3 (i, j) = cos 2π

I

2

(u 0 i + v 0 j) .

8

Note: I 3 = I 1 + I 2 . Show I 3 as as an 8 bpp gray scale image with full-scale contrast (it should look the same as the real part of I 1 ). Print out the real and imaginary parts of the centered DFT I 3 as 8 × 8 ascii floating point arrays.

Let I 4 be defined by I 4 (i, j) = sin 2π

(u 0 i + v 0 j) .

8

Note: I 4 = 1(I 1 I 2 ). Show I 4 as as an 8 bpp gray scale image with full-scale contrast (it should look the same as the imaginary part of I 1 ). Print out the real and imaginary parts of the centered DFT I 4 as 8 × 8 ascii floating point arrays.

(e) Let I 5 be defined by

I 5 (i, j) = cos 2π

8 (u 1 i + v 1 j) ,

where u 1 = 1.5 cpi is the horizontal frequency and v 1 = 1.5 cpi is the vertical fre- quency. Show I 5 as an 8 bpp gray scale image with full-scale contrast and print out the real and imaginary parts of I 5 as 8 × 8 ascii floating point arrays. Discuss the

appearance of I 5 as compared to I 1 -

I 4 .

2. Obtain the image lena.bin from the course web site. We will call this image I.

(a)

(b)

(c)

Compute the image J 1 = AVE[I, B], where B = SQUARE(49) and where the reference point is the center pixel of B (this is just a 7×7 average filter). Compute the image J 1 by looping over image pixels and handle edge effects by periodic extension of the image I. This makes the operation equivalent to the circular convolution J 1 = I B. Show the original and filtered images as 8 bpp gray scale images with full-scale contrast.

Compute the centered log-magnitude spectrum log[1 + | I |] and show it as an 8 bpp gray scale image with full-scale contrast.

Now implement the same filtering operation as in part (a) above by pointwise multipli- cation of DFT’s. Let the 256 × 256 image K represent the window B, so that K has 49 pixels with value 49 and the rest of the pixels in K are equal to zero. The center of the square window should be the upper left corner of K, so that the square is split across the four corners of the image K. Show the image K and its centered log-magnitude spectrum as 8 bpp gray scale images with full-scale contrast. Compute the DFT of the result image J 2 by spectral multiplication according to

1

J 2 = I K.

Use the inverse DFT to compute the image J 2 . Show J 2 and its centered log-magnitude spectrum as 8 bpp gray scale images with full-scale contrast. Note: you should see that J 1 = J 2 .

DUE: 3/28/2012