Sunday, 11 August 2013

Activity 8 - Enhancement in the Frequency Domain

This activity is focused on noise cancellation or removal in images. Main concepts to be used in this activity focuses on application of Fourier Transform via FFT in 2D space and convolution, both of which was discussed in Activity 7. But before we go into noise cancellation, we will first look into various insights into convolution and FFT.

First we synthesize a 200x200 binary image of various shapes, as shown in the top row of Figure 1. Now the first image from the left, shows two equally spaced dots, but mathematically this can be viewed as two Dirac deltas, and as such we can see that the Fourier of such an image results in a sinusoid. Though its sinusoidal pattern is not as clear as plotting it in 3D, the varying intensity of the plot should suffice in supporting the statement. Increasing the distance between the two dots would result in a higher frequency sinusoid, as would decreasing the pixel distance result in a lower frequency sinusoid. From the previous Activity it was shown that by applying fft2() to an image would give of its representation in frequency space but applying it again would revert it back to the original image. Also recall that FT represents data into its frequency components, now assuming that the two equally spaced dots represent the frequency of a sinusoidal function then applying fft2() would result in an image representing such a function, as was shown. 

Figure 1.(Top row) Synthesized images of equally spaced dots, circles, squares and Gaussians(Bottom Row) Resulting Fourier Transform  

The second image is that of two equally spaced circles, which is a convolution of the previous spaced dirac delta and a circle. As such the resulting transform of the two should be a element-per-element multiplication of the transforms of the two images as shown in Figure 1. The output is that of a sombrero function superimposed upon a sinusoidal function which are the transform of a circle and of two Dirac deltas, respectively. This concept can also be observed in the other two images in Figure 1. The third and fourth top row image shows the convolution of a square and of a Gaussian to two Dirac deltas, respectively. Since the transform of a square is a sinc function and the transform of a Gaussian is a Gaussian the output is as shown in Figure 1. Note however that increasing the variance of the Gaussian in the input will lead to a smaller Gaussian in the frequency space and decreasing variance will result in the opposite.

The process in which the previous images can be explained by performing the following. Synthesizing 10 Diracs randomly distributed along a 200x200 black image, and a random pattern, as shown in Figure 2. Taking the transforms of the two images and performing element-by-element multiplication of the results then applying fft2() to the product would result to the image shown in Figure 3. As can be seen the pattern is superimposed on each dot from the earlier image. In the same manner, one can replicate the images in Figure 1.

Figure 2.(Left) Randomly placed Dirac Deltas. (Right) Diamond Pattern

Figure 3. Resulting Fourier Convolution of the images in Figure 2. Image was flipped for comparison.

Now implementing fft2() to equally spaced vertical lines, shown in Figure 4, will result to fringes, also shown in Figure 4. The Fourier transform sees that image as an array of equally spaced Dirac Deltas or Dirac Delta train, applying fft2() to such an array would result in a Dirac Delta train with a spacing, 1/T, equal to the inverse of the spacing in the spatial domain, T. Thus as shown in Figure 4, as the spacing between the dirac train increases, the spacing between the fringes lessens.

Figure 4. (Top Row) Equally spaced dirac trains. (Bottom Row) Fringe Patterns.

Returning to noise cancelling, noise can be defined as unwanted signal that is considered to be spurious and extraneous information, and is usually a by-product of how the image was captured. In Figure 5 for example, the image exhibits equally spaced vertical lines similar to those of Figure 4. These are the result of digitally stitching of 'framelets' in order to form the image. Analyzing the transform of the image, the fringe pattern which was shown earlier, can also be observed both horizontally and vertically. A mask or a filter was thus synthesized in order to remove the noise, which consisted of pattern much like a crosshair since the middle part of the transform has to be kept the same since low frequency is usually the domain of important image data. After performing element-per-element multiplication between the mask and the FT of the image, performing fft2() to the result gives of a filtered image without the prevalent noise observed in Figure 5.

Figure 5. Moon image with equally spaced vertical lines [2]

Figure 6. (Left) Fourier Transform of Figure 5. (Middle) Mask. (Right) Superimposed masked on FT of the Moon image

Figure 7. Filtered image after applying mask

Another way of performing this is by measuring the pixel distance between each vertical line, then from that replicate the pattern of the vertical lines. Take the transform of the pattern perform element-per-element division from the transform of the image in Figure 5, the resulting image should give an output similar or identical to that of Figure 7.

The last image to be to be subjected to noise cancellation is, shown in Figure 8, a painting by Dr. Vincent Daria. Shown in Figure 9 is the transform of the image. Since no pattern can be generated quickly, a quick way to create a mask is to threshold the transform and convert it to binary. Now getting the negative of the binary and superimposing a circle to the center and the mask for the image is complete. The result is shown in Figure 10.

Figure 8. Oil Painting by Dr. Vincent Daria

Figure 9. (Left) FT of Figure 8. (Middle) FT after applying the threshold. (Right) Filtered FT

Figure 10. Filtered image from Figure 8


In this activity I give myself a grade of 10, for completing the task and for being able to comprehend and explain the performed tasks.

Reference:
[1] M. Soriano. "Enhancement in the Frequency Domain". Applied Physics 186 2013. University of the Philippines.
[2] lpi.usra.edu. "Apollo 11 Mission". Accessed on July 30, 2013.  http://www.lpi.usra.edu/publications/slidesets/apollolanding/ApolloLanding/slide_05.html


No comments:

Post a Comment