CS 7321 Winter 1998

PS#2 Solutions by Rob Orr

Images and Spatial Properties


Index


How I solved it

  1. First I created the initial image (a) in the handout (3 black bars on a white background)
    1. I used the Matlab built-in functions ones() and zeros()
  2. Then I computed the FFT of (a) to generate the power spectrum (d); to this I:
    1. wrote a function that squares the in put matrix element by element (I was unclear about the difference between the "^" and ".^" operators in Matlab--my function verified their operations); see rjoSquare.m below
    2. transformed to frequency using fft2()
    3. squared the real and imaginary parts separately and added them
    4. did an fftshift() on the resulting image to transform the FFT into polar coords.
    5. took 2 logs to transform the contrast to a usable range
  3. To generate (b), I high-pass filtered the image in the frequency domain, convert the image back to the image domain, and rotate the image.
    1. To high-pass the image, I created a function (rjoCircle.m below) that creates circular masks anywhere in an arbitrary sized image.
    2. I created a mask which removes the 'center' of the image in frequency space and multiplied the image in frequency space by this mask. I needed to use fftshift() twice in this process.
    3. Then I converted the image back to image space using ifft2().
    4. The rotation was accomplished with the imrotate() function.
  4. To generate (e), I simply computed the fft of (b)
    1. use fft2() to transform into frequency space
    2. compute power spectrum in the same was as in (d) (see above)
  5. To generate (c), I low-passed (a) in a similar way to (b):
    1. I created a mask that leaves the center and removes the outer part of the image in frequency space, and then myultiplied the image in frequency space by this mask. Again, I used fftshift() twice in this process.
    2. Convert back to image domain by using ifft2().
  6. The last image, (f), was generated by taking the fft of (c)
    1. I used fft2() to convert to freq. domain
    2. I computed power spectrum as in (d)
    3. I enlarged the image by a factor of 2 and copped out the middle
    4. I then inverted and adjusted the colormap to show the results a little better

to TOP


Assumptions and Weaknesses

I made the following assumptions:

  1. High-pass filtering and low-pass filtering should be done in the frequency domain
  2. Matlab would be easy to use

I think the major weakness of my solutions are:

  1. I didn't generalize my scipt so that it could take an arbitrary input image
  2. Low-pass filtering could have been performed more easily by using a simple Gaussian filter in the image domain
  3. Simple edge-detection could have been substituted for high-pass filtering

to TOP


Improvements and Possible Future Work

I think that this can be improved by doing the following

to TOP


Results

Panel (a):

Panel (d): the power spectrum of (a).

Panel (b): this is (a) high-pass filtered and rotated 30 degrees clockwise

Panel (e): the power spectrum of (b).

Panel (c): low-pass of (a).

Panel (f): the power spectrum of (c).

to TOP


What I Learned

  • How to transform an image from image space into frequency space in Matlab
  • The intricacies of computing the power spectrum
  • What the various parts of the power spectrum image correspond to (high frequencues vs. low frequencies)
  • How to high-pass filter and low-pass filter an image in frequency space
  • How to write functions in Matlab
  • to TOP


    Source Code