Monday, July 20, 2009

Activity 7 Enhancement in the Frequency Domain

In the past few activities we familiarized ourselves with the use and applications of the 2-dimensional Fourier Transform. Along with the basic properties of the 2-dimensional FT,we also learned and observed the effects of imaging with convolutions and correlations. When we think about it, the past few activities were exercises geared to build on our skills for manipulation in the inverse space or frequency domain. In this activity we utilize the skills we learned to do image enhancements in inverse space.

Most of the time, when we do image processing and analysis, it is more appropriate to do manipulations in the frequency domain. For example, unwanted repetitive patterns over an image would be very difficult to remove without loss of important information. Such tasks can be easily handled when by going into the frequency domain. As we have seen in the previous activities, repetitive patterns are just represented by a few points or lines in inverse space and removing them becomes much simpler. In this activity we will be doing similar tasks in enhancing images of fingerprints, paintings, etc.

The first part of this activity is again aimed to further familiarize ourselves with inverse space. Here we compare the FT of different structures, namely: single points, circles, squares, and gaussians. We can see on Figure 1 below shows the Fourier transform of two single pixel dots compared with the Fourier transforms of two circles of different radius. As expected the Ft of the single pixel dots are multiple parallel lines just like a sinusoid in activity 6. On the other hand the FT of the two circles are very similar to the multiplication of the FT of the two dots and that of a circle (airy disk). When we think about it the image of these two circles is just like the convolution of the two dots and a circle of the same radius. Hence in inverse space the result should be the product of their FT, as seen in figure 1. Increasing the radius of the circle simply results to a decrease in the size of the FT pattern, similar to our results in previous activities.


Figure 1. 1st column: Two single pixel dots and its FT.
2nd-5th column: Two circles of varying radius with FT

Figures 2 and 3 below are just like figure 1 except that the objects are squares and gaussians respectively. Again as expected the FT patterns are simply the product of the FT of the two dots and the objects. That is the FT of a square is two perpendicular sinc patterns and for a gaussian the FT is also a gaussian. The behavior of the FT with varying object size is still the same (inversely proportional).


Figure 2. 1st column: Two single pixel dots and its FT.
2nd-5th column: Two squares of varying side length with FT


Figure 3. 1st column: Two single pixel dots and its FT. 2nd-5th column:
Two gaussians of varying spread (standard deviation/sigma) with FT

Next we explore the difference in the FT of an inverted gaussian. Figure 4 shows the gaussian and inverted gaussian patterns with different standard deviations. When we look at their normalized FT we see no difference at all so instead we compare their Real and Imaginary parts.


Figure 4. Double Gaussian pattern of different spreads and their inverted counterparts.

Figure 4 and 5 shows the comparison of the real and imaginary parts of the gaussian and inverted gaussian FT's. First let me say that though the images look like they are just flat gray images there are actually fine detail around the center which can be seen when the images are enlarged. Still even with very close inspection there are hardly any difference with the gaussian and inverted gaussian. But this is actually expected since inverting the gaussian simply involves multiplying by -1 which can be factored out of the transform. This simply results to a switching of the high and low values of the FT Real and Imaginary parts which is, in this case, hardly distinguishable.


Figure 5. Real part of the Fourier transform of the gaussian and inverted gaussian. The large image corresponds to the first gaussian and inverse gaussian pattern (figure 4) and the other three pairs are for the succeeding gaussian patterns.


Figure 6. Imaginary part of the Fourier transform of the gaussian and inverted gaussian. The large image corresponds to the first gaussian and inverse gaussian pattern (figure 4) and the other three pairs are for the succeeding gaussian patterns.

The second part of this activity involves enhancing a fingerprint image using inverse space filtering. We do this by applying a mask to remove the 'unwanted' regions in the FT of the finger print. Then we take the inverse Fourier transform of the masked FT and hope to obtain clearer and sharper fingerprint pattern.

Figure 7 shows the original fingerprint image and its Fourier transform. Looking at the original image we see that aside from the fingerprint a background pattern is present. This background pattern is probably the grain of the paper which only interferes with the fingerprint pattern. We will remove this background by applying a mask on the FT of the image. To create the mask we must first observe the FT pattern and determine which regions most likely contribute to the fingerprint. Once we have determined this region we will create a mask that only retains this part of the FT.


Figure 7. Original fingerprint image and its FT.

We can see from the FT in figure 7 that the center, having a much higher magnitude, contains most of the information of the image. Removing the center would result to losing not only the background but virtually the whole image. We also note that there are also two curved regions in the FT that are brighter than the other areas and most likely contain information on the fingerprint. Using these observations we now create a mask that enhances this regions hoping that it would result to an enhanced fingerprint.

Figure 8 below shows three different filtering masks I used, hoping to enhance the fingerprint. The first mask was made by simply blacking out all unwanted regions in the FT. The second mask was generated by creating two gaussians and rotating them about the center. Finally the last mask is a convolution of 2 gaussians with the first mask. Each of these masks highlights the regions I mentioned above and should produce an enhanced fingerprint. But as I found out using just one of these masks did not enhance the fingerprint enough to be considered a successful enhancement. So after numerous trials and even more errors I ended up using a combination of these three patterns, multiplying them with different scaling factors, to produce a good enough enhancement of the fingerprint (figure 9).


Figure 8. Three different filtering mask used together to
obtain an enhanced fingerprint pattern.

Figure 9 is a comparison of the original fingerprint and the enhanced one. The left image is the original fingerprint which was inverted and cropped. The right image is the resulting enhancement after the left image was filtered with the masks in figure 8. Comparing the two images we first note that in the enhanced fingerprint the background paper grain patter is not visible anymore. Moreover the text on the background have been significantly reduced. The most notable improvement though is that the fingerprint itself is much clearer. The lines are thinner and sharper, the overall fingerprint is also more uniform in color, and some lines are now distinguishable. But looking at the right edge of the fingerprint we can see some loss. A small part of the lower right edge of the fingerprint can not be seen clearly. Still this is a considerable improvement from the original.


Figure 9. Inverted original fingerprint image and the enhanced fingerprint image using frequency domain filtering.

The third part of the activity involves removing vertical lines found in a composite image of stitched photographs of the moon. This task is considerably much simpler compared to the enhancing a fingerprint. For this task it is clear what structure of the image we do not want and we simply need to create a mask that removes this in the frequency domain.

Figure 10 shows the original and gray-scale image of the moon and in this two images the unwanted vertical lines are clearly seen. But from our previous activities we know that this array of vertical lines is represented by areas along the horizontal of the FT so we create a mask to filter this region out (figure 10).


Figure 10. Original moon image and below it is the gray-scale image.
To the right is the FT and to the lower right is the filtering mask used.

Using the mask in figure 10 we removed the vertical lines and the result is seen on figure 11. The left image in figure 11 shows the resulting image after the mask was applied. It is clearly seen that there are no more vertical lines present in the image. But the final image is also seen to be darker than the original and the lighting is also different. This is probably due to some losses caused by the mask but was not enough to distort the detail in the photograph. Still the objective was achieved and there was very little lost information.


Figure 11. Gray-scale images of the original moon surface and
the resulting image after the mask was applied.

The last part of this activity is aimed to enhance an image of a section of a painting. The canvass weave is clearly seen in this image and distorts the brush strokes and the actual painting. Again we use a mask to remove this canvass weave and recover a clearer image. Figure 12 shows the original and gray-scale image of the painting as well as the FT. We know that since the canvass weave is repetitive then its image in the inverse space are probably symmetric points. So from the FT we identify areas that might be part of the weave and then create a mask to remove this areas. The mask I used is also shown in figure 12. We can see that the mask removes only selected symmetric bright points in the FT.


Figure 12. Original and Gray-scale image of the painting, the Fourier transform
and the mask used to remove the canvass weave.

Figure 13 shows the resulting image after the mask was applied. It is clearly seen that most of the canvass weave has been removed and the painting has much more distinguishable detail. But when we look closely there are still some traces of the canvass weave. The enhancement may not be perfect but the canvass weaved was sufficiently removed, enough to highlight the brushstrokes and details of the painting.


Figure 13. Gray-scale image of the painting and the
resulting image after applying the filtering mask.

Finally we look at the Fourier transform of the mask with the idea that it should result to the canvass weave, but as seen in figure 14 this is not exactly the case. The FT of the mask does resemble the canvass weave but the intensity is not uniform. An elliptic figure seems to be distort the canvass weave pattern. And also along the edges there are lines that cut across the uniformity of the pattern.


Figure 14. Inverted image of the mask and the FT. The FT mimics
the canvass weave pattern with some obvious distortions.

I got the fingerprint image using google image search but I forgot where (sorry). I give my self a grade of 9 in this activity since the results were not perfect.

No comments:

Post a Comment