1 2D Discrete Fourier Transform [6 Points]

4
Signal and Image Processing - Assignment 2 Assigned March 21 st Due April 23 rd 23:59 Time you spent on this assignment: hours The maximum amount of points awarded for this assignment is 40 points. There are 10 extra points that can be obtained by doing the bonus tasks 3(f) and 3(g). These extra points will be added to the total score of this assignment. If you exceed the maximum of 40 points in this assignment, the extra points will still be calculated into your final grade. 1 2D Discrete Fourier Transform [6 Points] Compute and display the magnitude of the DFT of the following pictures. The Matlab function for the 2D DFT is fft2. Use fftshift to move the DC component to the center, and use the logarithmic transformation so that your results look like Figures 4.24(d) and 4.29(b) from the Gonzalez & Woods book (also in the slides), respectively. In both cases use imagesc with clim=[5 13] to display the DFT log magnitude. Figure 1: Figure 4.24(a) and 4.29(a) from the Gonzalez & Woods book. The images can be downloaded from the website: http://vda.univie.ac.at/Teaching/SIP/17s/Lab2/424a.png http://vda.univie.ac.at/Teaching/SIP/17s/Lab2/429a.png 1

Transcript of 1 2D Discrete Fourier Transform [6 Points]

Signal and Image Processing - Assignment 2

Assigned March 21st Due April 23rd 23:59

Time you spent on this assignment: hours

The maximum amount of points awarded for this assignment is 40 points. There are10 extra points that can be obtained by doing the bonus tasks 3(f) and 3(g). Theseextra points will be added to the total score of this assignment. If you exceed themaximum of 40 points in this assignment, the extra points will still be calculated intoyour final grade.

1 2D Discrete Fourier Transform [6 Points]

Compute and display the magnitude of the DFT of the following pictures. The Matlabfunction for the 2D DFT is fft2. Use fftshift to move the DC component to thecenter, and use the logarithmic transformation so that your results look like Figures4.24(d) and 4.29(b) from the Gonzalez & Woods book (also in the slides), respectively.In both cases use imagesc with clim=[5 13] to display the DFT log magnitude.

Figure 1: Figure 4.24(a) and 4.29(a) from the Gonzalez & Woods book.

The images can be downloaded from the website:http://vda.univie.ac.at/Teaching/SIP/17s/Lab2/424a.png

http://vda.univie.ac.at/Teaching/SIP/17s/Lab2/429a.png

1

2 Textbook Problem 4.33 [6 Points]

Figure 2: Textbook Problem

Consider the images shown in Fig. 2. The image on the right was obtained by: (a) mul-tiplying the image on the left by (−1)x+y; (b) computing DFT; (c) taking the complexconjugate of the transform; (d) computing the inverse DFT; and (e) multiplying the realpart of the result by (−1)x+y. Explain (mathematically) why the image on the rightappears rotated 180 degrees. Explain what each step does to the image.

3 Image Transformations [28 Points]

The goal of this sections is that you get an idea about lattices structures, frequency andbandwidth of signals and filtering. You can use Mathlab/Octave or any programmingor scripting language. You can use the Mathlab Image Processing Toolbox or OctaveImage Package in this section. A good documentation for them can be found here:https://www.mathworks.com/help/images/index.html

Any other Matlab/Octave toolbox, or C/C++/Java/etc libraries have to be confirmedby us before being used for this assignment.

If you are using Octave: Your code will be tested in Matlab, therefore it should beconsistent with the Matlab syntax. Octave also supports C-Style programming, whichis not acceptable for this course.

If you are using other programming languages: Please provide similar functionsas shown below. Your code also needs to include a Makefile if it has to be compiled and

2

• The Octave Image Package can be downloaded from:

https://octave.sourceforge.io/image/

• Installation of packages in Octave is described in this article:

https://www.gnu.org/software/octave/doc/v4.0.1/

Installing-and-Removing-Packages.html

• To use the package you have to load it using the following command:

pkg load image

Figure 3: Using the image package in Octave

a README.txt explaining the full procedure which has to be followed to test your codeand call all functions.

For each task explain how you solved the problem and why you are doing it this way.Downsampling tasks are without smoothing filters unless specified otherwise.

For this assignment you are not allowed to use the following Matlab/Octave functions:

• imresize: resizes an image

• imrotate: rotates an image

• imtransform: applies 2D spatial transformation on images

• imwrap: applies geometric transformation on images (similar to imtransform)

You can use these functions to compare your results with them and test your algorithm,but your submitted functions should be written without these functions.

(a) Download the original, 6282 × 4249 high resolution JPEG image from: http:

//vda.univie.ac.at/Teaching/SIP/17s/Lab2/650years.jpg

(b) Resize the image to 700 × 700. Since it changes the aspect ratio of the image,your final image should look stretched vertically. [6 points]

(c) Assume that the image is black outside its borders. Rotate the 700 × 700 imagefrom the previous step by 30 degrees. To include all the input image, your finalimage would be 957 × 957. [8 points]

3

(d) Generate the 957 × 957, 30 degree rotated image directly from the original image.This means that there is only one re-sampling operation on the image. [10 points]

(e) Which one has higher quality, (c) or (d)? Use the higher accuracy as the groundtruth and calculate the mean squared error (MSE) for the second one. [4 points]

(f) (OPTIONAL) Downsample the original image to 116

× 116

of the original sizeusing Fast Fourier Transform (FFT): http://spiedigitallibrary.org/data/

journals/appres/929364/JARS_8_1_083683.pdf [+5 extra points]

(g) (OPTIONAL) Create a ”Blur-Aware Downsampled Image” in 116

× 116

of thesize of the original image: http://www.cs.ubc.ca/~heidrich/Papers/EG.11.

pdf [+5 extra points]

You need to submit a PDF report and one Matlab/Octave function for each task, all inthe same folder. Please write your name and student ID on top of each Matlab file aswell as the PDF report. Feel free to define other auxilary functions. I should be able totest your code with the following sequence of commands:

img = imread(’650years.jpg’);

imgB = resize700(img);

imgC = rotate30(imgB);

imgD = rotate30 700(img);

imgMSE = taskMSE(imgC, imgD);

imgF = taskF(img);

imgG = taskG(img);

4