Tuesday, August 10, 2010

Enhancement in the Frequency Domain

     In this activity, image enhancement through filtering in the frequency domain will be demonstrated.  This is done by creating filter masks to block out unwanted frequencies.  Careful consideration of the convolution theorem is needed in creating filter masks, and this will be the first part of the activity.  This will be followed by  ridge enhancement of a fingerprint image, line removal on a composite image, and removal of the canvas pattern on an image of an oil painting.

A. Convolution Theorem
     In paint, two dots symmetric along the x-axis were made and then loaded into Scilab.  The FT was taken, as shown in figure 1.  


Figure 1.  Two dots symmetric along the x-axis (left) and its FT (right).

Figure 2. Dots with increased radius (left) and their corresponding FTs.

     As can be seen, the FT changed drastically when the diameter of the aperture is changed.  For two pixel dots, the FT is a sinusoid (figure 1).  But when the diameter is increased, the FT becomes an Airy pattern multiplied by a sinusoid.  To explain this, the two dots represents dirac deltas.  When convolved to a circular pattern, the result will be the two circular apertures.  According to the convolution theorem, the FT of the convolution of two functions is equal to the product of the FT of the individual functions.  Since the FT of two dirac deltas is a sinusoid and the FT of a circular aperture is an Airy pattern, the resulting FT will be the product of the two, as seen in figures 2-3.  As the radius of the apertures were increased, the FT becomes smaller.  This is due to the inverse property of the FT.

Figure 3.  Two squares of increasing width (left) and the corresponding
FTs (right).

     The same thing was done for a square and gaussian aperture (figures 3-4).  The FT becomes smaller as the width of the square is increased.  For the gaussian, the spacing of the lines in the FT becomes smaller as the radius is increased.  Like in the previous case, the resulting FT is the product of the FT of two dirac deltas and the FT of a square aperture, or the FT of the gaussian aperture.

Figure 4.  Two gaussians of varying variance (left) and the corresponding FT (right). 

     Next, a 200x200 image with 10 randomly placed dots were made in Paint.  This is convolved with a pattern shown in figure 5 (left) using the function imconv() in Scilab.  The result is shown in figure 6.  The convolution is the smearing of one function to the other, which explains why the result shows the pattern at the locations of the dots.  
Figure 5.  An image approximating 10 dirac deltas at random locations (left) and an arbitrary 
3x3 matrix pattern (right).

Figure 6. Convolution of the images at figure 5.

     Next, a 200x200 array with equally spaced 1's were made in Scilab.  The FT was taken, and it was noticed that as the spacing is increased, the spacing in the FT domain decreases.  This illustrates the inverse property of the FT.

Figure 7.  A grid pattern of increasing width separation (left)
 and the corresponding FT (right).

B.  Ridge Enhancement
     Now, using filtering in the FT domain, an image will be enhanced.  I looked for an image of a fingerprint that is not yet binarized on the internet.  The FT was taken, as shown in figure 8 (left).  The ellipse part of the FT represents the signal of the ridges of the fingerprint, and this is what is important.  The other part of the FT will be masked out.  Figure 9 shows the mask pattern and the multiplication of it to the FT.  Then, the absolute value of the inverse fft was obtained, showing the filtered image.  Figure 10 shows the comparison of the unfiltered and filtered image.  It can be seen that the filtered image shows finer and more defined ridges.


Figure 8.  An image of a fingerprint taken from here (left) and its corresponding FT (right).

Figure 9.  Designed filter (left) and masking it to the FT of the image (right).



Figure 10.  Fingerprint before (left) and after (right) filtering.

C.  Lunar Landing Scanned Pictures: Line Removal

     Filtering in the Fourier domain will also be utilized for this part.  The vertical lines in the image is from combining individually digitized framelets.  To remove this, the horizontal line in the FT will be removed.  Figure 13 shows the product of the mask and the FT.  Then, the absolute value of the inverse fft was obtained.  Figure 14 shows the image before and after filtering.  It can be seen that the vertical lines are removed.

Figure 11.Composite image from 
http://www.lpi.usra.edu/lunar/missions/apollo/apollo_11/images

Figure 12.  FT of the composite image in figure 11.

Figure 13.  Filtering in the frequency domain.


Figure 14.  Grayscale image of figure 11 (above), and the resulting image (below).

D.  Canvas Weave Modelling and Removal
     Next, the canvas pattern in this oil painting will be removed.  This canvas pattern is like superposition of sinusoids, so it is expected that the FT of this image will have dots.  Now,  the FT was taken, as shown in figure16.  There are dots as expected.  The mask is designed in such a way that the dots will be blocked out.  The mask and the FT was multiplied, and the absolute value of the inverse fft was obtained to get the modified image.  Figure 18 shows the comparison of the image before and after filtering, and it is clear that the weave pattern is removed.

Figure 15.  Detail of an oil painting from the UP Vargas 
Museum Collection.

Figure 16. FT of the oil painting image.

Figure 17.  Masking of the FT of the oil painting.


Figure 18.  Grayscale of the oil painting (above) and the resulting 
filtered image (below).


Figure 19.  Inverse color of the filter used for the filtering of the oil canvas.



Figure 20.  FT of figure 19.

Figure 21. Logarithm of the FT of the filter.

     Next, the question is: given the filter mask, how will you get the canvas weave pattern?  Answer: Get its FT!!  So, I edited the mask in Paint and reverted the colors.  Then, the FT was obtained.  Because the FT is small, I used the log value of the FT, as shown in figure 21.  The resulting FT is somewhat similar to the canvas pattern on the image.

     I would give myself a 10/10 for this activity.  I had given all required outputs and explained the results.  I would like to thank Joseph Raphael Bunao and Ma'am Jing for the helpful discussions.

No comments:

Post a Comment