Monday, July 13, 2009

A7 Enhancement In The Frequency Domain

Convolution is the smearing of one function against another so that the output looks a little like both. Mathematically it can be written as

In Fourier space, however, the convolution becomes a multiplication. That is the FT of a convolution of two functions in space is the product of the two functions’ FTs.

FT [ f g ]=FG

This is called the convolution theorem. It is this property of the convolution that makes it very convenient to do image enhancements and suppressions in the Fourier domain. We can just create a filter mask to remove or enhance some frequencies, multiply it to the image’s FT and do the inverse transform.

In this activity we first demonstrate some examples of convolution then use the theorem to enhance images.


A7A. Convolution Theorem


An image of a dot that is one pixel thick can be used to represent a dirac delta.We get the FT of two dots (dirac deltas) symmetric about the and see that it is a sinusoid pattern.



From the formula above, we can solve that the convolution of a dirac delta and a function f(t) results in a replication of f(t) in the location of the dirac delta.

A convolution of the two dirac deltas, above and a circle would just result to two circles in the locations of the peaks. From the convolution theorem, it can be predicted that the FT of this would just be a product of an Airy disk and the sinusoid pattern.

As the circle’s radius is reduced, the Airy disk becomes smaller. This can be seen in the images below. The sinusoid pattern however remains unaffected.

We already know from previous activities that the FT of a square is a sync pattern. The FT of the convolution of a square and two dirac deltas would therefore be just a sinc pattern with sinusoid linings. Increasing the square size reduces the size of the sinc pattern. The sinusoid retains its frequency.



Next the squares are replaced by Gaussians of varying variance. The resulting FT is that of a Gaussian with sinusoid patterns. Like the circle and square pairs the FT pattern becomes smaller as the variance becomes bigger.



Lastly, the values of the Gaussian were inverted as imaged below. Checking its fft, I found out that the values were just the negative of that of the fft of the original Gaussian.



The program that I used for this part is as follows.

clc;

x = [-1:0.005:1];

[X,Y] = meshgrid(x);

/////dots

rad=0.25;

r1 = sqrt((X-0.5).^2 + Y.^2); r2 = sqrt((X+0.5).^2 + Y.^2);

dots = zeros(size(X,1), size(X,2));

dots(find (r1 <=rad )) = 1.0; dots(find (r2 <=rad )) = 1.0;

//one pixel dots

//dots(find(X==0.5 & Y==0))=1;dots(find(X==-0.5 & Y==0))=1;

//////squares

d=0.25;

square= zeros(size(X,1), size(X,2));

square(find(abs(X-0.5)<=d & abs(Y) <=d))=1.0;

square(find(abs(X+0.5)<=d & abs(Y) <=d))=1.0;

/////// gaussian

sigma=0.005;

r1=sqrt((X-0.5).^2 +Y.^2);r2=sqrt((X+0.5).^2 +Y.^2);

g1=exp((-(r1).^2)/sigma^2) ;g2=exp((-(r2).^2)/sigma^2);

gaussian = zeros(size(X,1), size(X,2));

gaussian= g1 + g2;

gaussian=gaussian/max(gaussian);

/////// invert gaussian

invgaussian=1-gaussian;

image=square;

scf(1);

subplot(1,2,1);

imshow(image,[]);

//scf(2);

subplot(1,2,2);

imshow(fftshift(abs(fft2(image))),[]);


A7B Fingerprint Ridge Enhancements

Below is an image of a fingerprint. Notice that some of the ridges are indistinct and that some parts are smudged.



Our task was to do filtering in the frequency domain such that the smudges are removed and the ridges are enhanced. The fft of the fingerprint is as shown below


I interpreted the higher frequency areas to be from the ridges while the rest are from the noise.

For my first set of filters, I thought of using the im2bw() command to threshold the fft image so that only the high frequency areas are imaged. The image below shows the mask, the masked fft and the enhanced fingerprint for 0.2, 0.3 and 0.4 threshholds. We can see that for 0.2 and 0.3 although the ridges are enhanced so are the smudges. Threshold 0.4 clears the smudges but some information are also erased.



Next I tried the contrast enhancement and the thresholding of GIMP to create the filters. The firrst two filters did enhance the ridges...



but my best result was


Lastly, taking an idea from the first part of activity A, I tried an inverted Gaussian filter.



A7C. Line Removal
The image of the lunar landing below has a series of vertical lines in it.


We know from our previous activities that these lines would correspond to the bright spots aligned horizontaly on the fft.

We therefore use the filter


The enhanced image is now free of lines.



A7D Removal Of Canvas Weave

Th
e painting image below has its canvas weave pattern showing through.
From previous activities, we know that the cross hatch pattern are just crisscrossing sines and will therefore show up in the fft as pairs of dots.
To filter out the dots, we use
The enhanced image is

We expect the filtered out pattern to look like the weave when it is inversed fft.
In this activity, I give myself a grade of ten because I was able to do all that is required.

No comments:

Post a Comment