Tuesday, July 9, 2013

Activity 8 : Enhancement in the Frequency Domain

(Welcome, Interwebs traveler. A note before you go: please click any image to view in enlarged/theater mode. Now explore on!)

In our previous activities, images were manipulated through their cumulative distribution function. For this week's activity, we manipulate images in the frequency domain to remove certain components present in the image. The components we aim to remove are repetitive in the spatial domain. Examples of these are lines produced from stitching images and the canvas weave of a painting, and we will attempt to remove them from our images in a section below.

But first, we review a few Fourier transforms (FT) of repeated shapes.

Fourier Transform of Repeated Shapes

Two Dots


We recall that two white dots on a black background represent two Dirac deltas in two-dimensional (2D) space. We also recall that two Dirac deltas symmetric along one axis is the FT of a cosine wave [1]. Assuming the deltas are present in the frequency domain and taking the 2D fast FT (FFT) of the deltas to convert them back to the spatial domain, we obtain the plot in Figure 1(b).

Figure 1. (a) Two dots representing two Dirac deltas in the 2D image plane.
(b) Corresponding 2D FFT of the deltas.

Two Circles


Figure 2(a) is a row of two circles of different radii, increasing from the left to right columns. Figure 2(b) shows the 2D FFT of the circles. We can see that as the radii of the circles becomes larger, the FT shrinks.

Figure 2. (a) Two white circles placed on a black background,
with increasing radius r (left to right: 0.1, 0.2, 0.3, 0.4 and 0.5 a.u.).
(b) Corresponding 2D FFT of the circles in (a).

Two Squares


Figure 3(a) is a row of two squares of different side lengths, increasing from the left to right columns. Figure 3(b) shows the 2D FFT of the squares. As with the circles, the FT shrinks as the side length becomes larger. However, the FT is boxy in shape. Recalling our reference from Activity 7, particularly this file [2], we find the theoretical FT plot of a square. This is shown in Figure 4.

Figure 3. (a) Two white squares placed on a black background,
with increasing side length s (left to right: 10, 20, 30, 40 and 50 px).
(b) Corresponding 2D FFT of the squares in (a).

Figure 4. Theoretical FT of a square aperture (shown in the lower left corner).
The top view of the FT is shown in the upper left corner,
and the right side shows the 3D plot of the FT.

Two Apertures with Gaussian Gradient


Figure 5(a) is a row of two apertures with Gaussian gradient of different standard deviations, increasing from the left to right columns. Figure 2(b) shows the 2D FFT of the Gaussian apertures. The FTs also shrink as the aperture increases; however, the Gaussian FT is devoid of diffraction effects unlike the FT of the circles.

Figure 5. (a) Two apertures with Gaussian gradient placed on a black background,
with increasing standard deviation sigma (left to right: 0.1, 0.2, 0.3, 0.4 and 0.5).
(b) Corresponding 2D FFT of the apertures in (a).

Recalling our Activity 7, we know that we can use shapes in the frequency domain as transfer functions which simulate the passage or blockage of light at that plane, if we take the convolution of the object and the transfer function.

Convolution


We also recall our convolution from Activity 7 and perform another demonstration of it here. We take 10 white dots randomly placed on a 200x200 pixel black image, and convolve it with a 5x5 random pattern. Figure 6 shows the 200x200 image, the 5x5 random pattern, and the resultant convolved image.

Figure 6. (a) An image of 10 white dots randomly placed on a 200x200-pixel black background.
(b) Random patterns of size 5x5 pixels. (c) Corresponding convolved image
of (a) and (b) along the same columns.

We also investigate uniformly-spaced dots along the x- and y-axes, changing the distance d between each point. Taking the FFT of the uniformly-spaced dots (shown in Figure 7(a)), we find that the FT is a uniformly spaced grid. When d = 200, the FT begins to resemble a sine wave, which is expected because only 2 dots are left at this separation distance.

Figure 7. (a) Uniformly spaced dots along the x- and y-axes,
in increasing distance d (left to right: 2, 5, 10, 20, 50, 100 and 200 pixels).
(b) 2D FFT of the uniformly-spaced dots in (a).

Pattern Removal

Line Removal


As instructed, we attempt to remove the lines produced by stitching multiple images from the lunar orbiter. We use the image of the lunar surface in Figure 8(a), which apparently has white lines crossing the image at intervals. Figure 8(b) shows the FT of Figure 8(a). The white lines can be filtered by blocking the vertical line in the center of Figure 8(b), and we obtain the filtered image Figure 8(c).

Figure 8. (a) Image of the lunar surface with white lines at regular intervals;
(b) 2D FFT of the image in (a); and, (c) Filtered lunar orbiter image.

Weave Removal


The next task is to remove the canvas weave pattern on the image of the painting in Figure 9(a). I attempted to filter the other peaks and retain the central peak in the frequency domain, in the hopes that this will result in a filtered image. Unfortunately, this was not the case, as shown in Figure 9(b). In fact, a lot of the painting information is lost and the canvas weave is emphasized, which is the opposite of our desired effect. Boo :(

Figure 9. (a) Painting with a canvas weave pattern; and, (b) resulting image
after attempts at filtering. The attempts were unfortunately unsuccessful.

Grading

Based on the criteria, I believe I deserve a 9/10 because although I was unable to successfully filter the canvas weave from the painting, I was able to accomplish other parts of the activity.

This activity was a little bit stressful for me, because for some reason even if I was blocking peaks in the frequency domain for the painting, I did not seem to be blocking/filtering the correct peaks. :(

No comments:

Post a Comment