Thursday, September 23, 2010

Applying Fourier Transform: Clean and Clear

One very useful property of Fourier Transform we need to explore before diving into cleaning images is convolution. We need to explore what happens if we convolve certain shapes to dots and what is their corresponding Fourier transform. So we start with two dots, very basic.
Figure 1: Two Dots
So we get a sinusoid Fourier transform as expected. Now, what happens if we convolve it with circles?
Figure 2: Two Circles
If we remember the previous exercise, we can see that the resulting Fourier transform is just the convolution of the Fourier transform of two dots and the Fourier transform of a circle. Let us see if this holds for other shapes as well, how about a square?

Figure 3: Two Squares
Again, we see a convolution of the Fourier transforms of a square and two dots. So how about Gaussian with varying sigma convolved with two dots?

Two Gaussians with Sigma = 0.020
Two Gaussians with Sigma = 0.010
Two Gaussians with Sigma = 0.001
So we can see that as we decrease sigma, we increase the radius of the visible part. It can be argued that by reducing the sigma of the Gaussian, we approach two dots and results in producing a purely sinusoid.

What if we increase the dots and place them randomly in an image? Here we generate an image of random dirac deltas and convolve a 3x3 pattern of a cross. Its very interesting to see that the pattern showed on all the dirac deltas.
Random Dirac Deltas (left) and convolved with cross 3x3 pattern (right)

Now, lets examine the Fourier transform of an array of Dirac deltas using different modulo. By increasing the modulo, we can increase the distance between Dirac deltas. So, when we examine what happens when we take their Fourier transform.

Arrays of Dirac Deltas using Different Modulo

As we can see, the Fourier transform of an array of Dirac deltas is also an array of Dirac deltas but different spacing. We see that by increasing the modulo of the original image the resulting Fourier transform has decreasing spacing in frequency space.

After exploring these properties, we can now try and apply these methods on to cleaning images with patterned defects. We can start with the image of the Lunar surface.
Before (left) and After (right) Image Processing of Lunar Image

On the left we see the original image. We can see a series of vertical lines and horizontal lines. If we look at these images it can be seen as gratings along x and along y. We know that the Fourier transform of gratings is very similar to sinusoidal signals, wherein the frequency points are constricted to the axis. So to remove the noise, we take the Fourier transform of the image. Then, we can create a mask along the center of the image vertically and horizontally and zero those areas out. Then, take the Fourier transform once again to reconstruct the image.

Upon application of this mask, we notice a degradation of the image. This is because the center of the image contains data about the image rather than the noise. So, we restrict the mask by removing a certain radius around the center of the frequency space. Then, apply it to the Fourier transform of the image. The end result is the image above. As we can see, the vertical and horizontal lines are greatly reduced while the rest of the image remains intact.

How about fingerprints? Can we apply the same process to fingerprints? Why not?! Looking at the original image, we can see glare hitting the ridges of the fingerprint. If we can get rid of this, we can see a better contrast on the fingerprint itself.

Now, since the glare produces grating-like noise against the ridges, we can filter it out by applying the same technique as in the Lunar Surface image. But remember, data is stored in the center of the frequency space, so we create a mask that leaves the center alone. Upon application, we can see reduced glare while maintaining the resolution of the image. Also, the white border was also removed.

Before (left) and After (right) Image Processing of Fingerprint Image

Finally, let's try to clean up an image of a painting. The painting was done on a canvass. The problem is the canvass texture was shown in a high definition image of the painting. So let us try to remove the canvass weaving.

The logical mask would be the Fourier transform of an array of Dirac deltas that fits precisely the dots of the canvass weave. Since the dots are larger than 1 pixel, we convolve the array with circles. Finally, we try and find the correct modulo to fit the canvass weave. Unfortunately, the canvass weave has a more hexagonal pattern with circular pores than a simple alignment. So, we attempt to align the Dirac deltas to the canvass weave and take the Fourier transform of both the image and the mask. Then we apply the mask to the image and reconstruct the image. The result is the image on the right. We can see areas with improved texture. This will be the areas that I used to align the Dirac deltas. Unfortunately, the array did not align completely on the whole image. Hence, the canvass weaves remain in other parts of the image.

Before (left) and After (right) Image Processing of Canvass Weave Image

For this image I give myself a grade of 9 due to the lateness of my submission.

No comments:

Post a Comment