Wednesday, July 25, 2012

Enhancement in the Frequency Domain

I've been working with Fourier Transform since 3rd year. Back then, I didn't know that it would be one powerful transform that I would be using more often, be it in the field of image processing or signal processing.

This is one of those activities that really made me appreciate Fourier transform. Aside from its use on determining the frequencies in a signal, Fourier transform can also be used to enhance an image by blocking or putting a mask on unwanted frequencies.

A. Fourier Transform of Different Apertures

First, given two dots equally-spaced along the x-axis, applying Fourier transform would give you alternating dark and white bands. A dot is a representation of a dirac-delta.

Two dots symmetric along the x-axis and its FT modulus(left to right)

Two dots give you a cosine function in 2D as your Fourier transform. Replacing these dots with 2 circles give you an Airy pattern.

Circular Apertures and its FT modulus at varying radii

It can be observed that these circles are considered as circular apertures. Their Fourier transform is an Airy pattern. As the radius of the circular apertures increases, the Airy disc decreases in radius.

Square apertures and their FT modulus
Meanwhile, as the square aperture gets smaller, its FT widens. The gaussian aperture, on the other hand, has the same trend as the circular aperture except that, instead of varying the radius, we vary the variance.

Gaussian apertures and their FT modulus

It can be noted in the first two variances (0.1 and 0.2), the former resembles 2 dirac-deltas in space and the latter resembles 2 circular apertures along x-axis. This is the reason why the FT modulus of the first 2 gaussian apertures resemble the FT modulus of a dirac-delta and a circular aperture, respectively.


B. Inverse Fourier Transform

random points (left), arbitrary pattern (middle), Inverse Fourier Tranforn when the two are convolved (right)

When two images are convolved and their inverse Fourier transform are taken, the resulting image is just a product of the two images. The pattern adheres to the location of the dirac-deltas (dots). The image above shows how the Array Theorem works. When you a function and a dirac-delta, the functions will add linearly but shifted to an new location, depending on where the dirac-deltas are located.

original image (left) and FT of hte modulus (right)

The Fourier transform of the image on the left is the image on the right and vice-versa. As one increases the spacing in the original pattern, the spacing between the dots in the Fourier transform of the image is narrower.

C. Line Removal

Unwanted lines in a picture can be removed by creating a mask that filters these lines out.

(left to right) original image, FT of the image, mask, and masked image


In the final image, it can be observed that the visible lines have been removed.

D. Canvas Weave Modeling and Removal


(left to right) original cropped image, FT of the original cropped image, mask filter, result




After applying the mask, it can be seen that the weave pattern has been partly removed. Here is the Fourier transform of the inverted filter mask used.


Inverted mask filter (left) and its Fourier Transform (right)

The Fourier transform of the filter mask shows us the weave pattern in the painting that was removed. 

Despite the long hours of debugging, I enjoyed doing this activity. :)

Thus, I give myself a 13 for learning the techniques, applying what I have learned in my optics class and for patiently debugging my code until it gives the right results.

A big thanks to Eloi for the helpful discussions and to Mabel for helping me debug my code. :)

2 comments:

  1. What are the graphs in the middle column of the 2nd and 4th figure?

    ReplyDelete
  2. Hi, ma'am! Those were the results using imshow(). :)

    ReplyDelete