24/05/2018, 22:06

Image processing - Lab 1

In this laboratory problem, you will learn the MATLAB functions for computing 2D DFT and inverse 2D DFT, and become familiar with basic matrix operations. You will also examine effects occurred to each image as a result of applying different ...

In this laboratory problem, you will learn the MATLAB functions for computing 2D DFT and inverse 2D DFT, and become familiar with basic matrix operations. You will also examine effects occurred to each image as a result of applying different operations in the frequency domain.

You are asked to write a MATLAB program to perform the following tasks for the given test images. (Hint: You may want to consider the following MATLAB functions: imread, imwrite, fft2, ifft2, fftshift, abs and angle)

  1. Get the two images: lena.png and beckman.jpg.
  2. Zoom in a small part of the image to see the pixels separately.
  3. Compute the DFT F(x; y) and display the magnitude and phase of F(x; y)
  4. Keep the magnitude of F(x; y) and set the phase to 0 for each frequency sample. Take the inverse DFT, show the result and compare to the original images.
  5. Keep the phase of F(x, y) and set the magnitude to unity for each frequency sample. Take the inverse DFT, show the result and compare to the original images
  6. Keep the phase of F(x; y ) and replace the magnitude of each frequency sample by it square root. Take the inverse DFT, show the result and compare to the original images. You should observe an edge enhancement.
  7. Low-pass filter the test images. First use the rectangular low pass filter
H ( x , y ) = { 1 ∣ x ∣ < C x and ∣ y ∣ < C y 0 otherwise size 12{H ( x,y ) = left lbrace matrix { 1 {} # lline x rline <C rSub { size 8{x} } ` ital "and"` lline y rline <C rSub { size 8{y} } {} ## 0 {} # ital "otherwise"{} } right none } {}

Where Cx size 12{C rSub { size 8{x} } } {}and Cy size 12{C rSub { size 8{y} } } {}are the cut-off frequencies for x and y respectively. You may want to try for different Cx size 12{C rSub { size 8{x} } } {}and Cy size 12{C rSub { size 8{y} } } {}. For example, Cx=Cy=0.3 size 12{C rSub { size 8{x} } =C rSub { size 8{y} } =0 "." 3} {}.

This problem guides you to write program to perform spatial filtering of an image. This problem is generic, in the sense that it will be used in other problems to follow

  1. Use the image you have obtained in problem1

Construct the mask of the filter at various size and coefficients. You can try the following size 3x3 as examples

  • Mean filter
1 1 1
1 1 1
1 1 1
  • Sobel filter for vertical edges of size 3x3
1 0 -1
2 0 -2
1 0 -1
  1. Apply the filter to input images to see the results

With this problem, you will try the image filtering module built in problem 2 to implement the Laplacian enhancement introduced in the lecture

0 1 0
1 -4 1
0 1 0

Use frequency domain method to remove the black bars in lena-bar.png.

All the file including images and Matlab files are here.

0