Thursday, August 5, 2010

Activity 8: Enhancement in the Frequency Domain

Repeating patterns that are unwanted in an image can be removed by the use of masking in its Fourier domain. Since in Fourier space, histograms of frequencies are displayed, the frequency of the repeating pattern can be zeroed out and the desired frequencies in the image can also be enhanced. Two things about the convolution theorem must be taken into consideration in masking or filtering out undesired frequencies in the Fourier domain of an image. First is that the Fourier transform of two convoluted functions in space is the product of the two functions, that is,
The second is that the convolution of a Dirac delta function and a function f(t) results in a replication of the f(t) in the location of the Dirac delta.

A Convolution Theorem
Let's start of by creating two dots, which is exactly one pixel each, along the x-axis and are symmetric at the center. Now let's take its Fourier transform. The dots and its Fourier transform is shown in figure 1.
Figure 1. The image of the generated two dots (left) and its Fourier transform (right).

Now let's replace the dots with two circles with some radius r and again, let's take its Fourier transform.
Figure 2. An image of the generated circles and its Fourier transform.

Let's change it again with a square and then into a Gaussian and take its Fourier transform.

Figure 3. Images of the generated squares and Gaussians and their corresponding Fourier transform.

Now, we generate 200x200 array of zeros and randomly put 10 1's in it. These random positioned 1's will represent Dirac delta's. Then after that, we generate an arbitrary 3x3 pattern and and convolve it with the 200x200 array.
Figure 4. Image of the 10 randomly positioned 1's (left), convoluted image of the original image and the pattern (right), and the matrix of the pattern used (below).

We can see that in figure 4, the property of the Dirac delta in convolutions is clearly shown. The pattern was replicated where the Dirac deltas are located.

Let's now see what would be the effect of having an equally spaced Dirac deltas Fourier transformed.
Figure 5. Increasing equally spaced Dirac deltas and its corresponding Fourier transform.

As we can see from figure 5, the spacing of the Dirac deltas in real space is inversely proportional with the spacing of the Dirac deltas in frequency space. This is expected since frequency space is 1 over real space.

Fingerprints: Ridge Enhancement
In this part, we'll try to enhance an image of a thumbprint using manipulations such as masking of the image's Fourier transform.
Figure 6. A raw thumbprint that was obtained from http://media.photobucket.com/image/thumbprint/lsquared37/thumbprint.jpg

Taking the Fourier transform of the raw thumbprint in figure 6.
Figure 7. Fourier transform of the thumbprint in figure 6 in log scale.

Now let us use a Gaussian mask, shown in figure 8, to enhance the ridges in the thumbprint.
Figure 8. The mask that was used and the resulting filtered image of the thumbprint.

After the mask was applied to the image, the ridges became much more defined and more noticeable. However, maximum enhancement was not fulfilled since the undesired frequencies are not precisely obtained.

Lunar Landing Scanned Pictures: Line Removal
In this part, periodic undesired patterns are present in the image. The image was a photo of the moon and was obtained from the manual used for this activity.
Figure 9. Grayscaled image of the lunar landing taken from the manual of this activity.

As we can see from figure 9, there is a repeating pattern with respect to the horizontal axis. Now, taking the Fourier transform of this image to see the frequencies present in the image.
Figure 10. Fourier transform of the lunar landing image in logarithmic scale.

After using a specific mask to filter the unwanted frequencies that causes the periodic lines along the horizontal axis. The resulting filtered image is shown below.
Figure 11. Mask used (top) and the resulting filtered image (bottom).

We can see that the unwanted repeating lines are now filtered.

Canvas Weave Modeling and Removal
Lastly in this part, we'll try to remove the pattern produced by the canvas cloth in a painting. The grayscaled image of the painting is shown below.
Figure 12. Grayscaled image of the canvas.

Taking the Fourier transform of the canvas image and displaying it in logarithmic scale.
Figure 13. Fourier transform of the image in figure 12 displayed using logarithmic scaling.

Now using a mask that would filter out the undesired frequencies.
Figure 14. Mask for filtering out unwanted frequencies.

Now the resulting image after the masking is shown below.
Figure 15. Enhanced Canvas image.

Taking the inverse Fourier transform of the mask and comparing to the canvas pattern.
Figure 16. Inverse Fourier transform of the mask that was used in filtering.

We can see a resemblance on the criss-cross patter observed between the canvas weave and the inverse
Fourier of the mask that was used.

This activity take a long time to finish because of the filtering. But once you get the hang of it, the filtering
process is very fun and interesting. I would give myself a grade of 10.

References:
Dr. Soriano. Applied Physics 186 activity manual: A8 - Enhancement in the Frequency Domain. 2010.

No comments:

Post a Comment