Thursday, July 15, 2010

Entry 12: Fourier Transform Model of Image Formation

In this activity, we performed exercises to understand the properties of Fourier Transform.  Also, we applied the Fourier Transform technique to model image formation of a system of optical devices.  The rationale of this implementation lies on the fact that the projection of an image  through a lens at a large distance is equivalent to the Fourier Transform of the object.

The activity has four parts and each part introduces a different application of Fourier Transform on image processing.

The objective of the first part of the activity is to familiarize us with the nature of Fourier Transform.  It is inclined towards visualizing the effects of certain programming commands, related to Fourier Transform, on the original image.  We simulated some methods to emphasize some important concepts needed in applying Fourier Transform to an image.

Figure 1: First row - original images, second row - fft of images, third row - fftshifted second row, last row - fft of fft of original images.

In Fig. 1, the subject images - the circle and the letter A in the top most layer were subjected to a 2D Fourier Transform which results to the set of images shown on the second layer.  The set of images on the third layer is the result of using fftshift() to the images on the second layer.  The lowest layer represents the subject images after undergoing two successive 2D Fourier transformations.

It is observed in the images after applying Fourier Transform that most of the values are located at the corners of the image.  When fftshift() was applied to it, the diagonal quadrants of the images in the second layer were interchanged resulting to the images in the third layer.  Hence, the fftshift() function corrects the redistribution of the quadrants after applying the 2D Fourier Transform to the original image.

Observing the lowest layer in Fig. 1, it can be concluded that two successive application of 2D Fourier Transform to an image results to an inverted version of the image.

Now, in the second part of the activity, the method of Convolution is introduced.

Figure 2: Convolution of circles with varying radius and the letters VIP.

Convolution, basically, is the combination of two objects (in our case - images) to obtain a resulting object having the characteristic of the two original objects smeared together.

In Fig. 2, the top layer are circles with varying radius, the middle layer is the image to be convolved with the circles and the bottom layer shows the images of the convolution of the top and middle layers.

It can be inferred here that the smaller the radius of the circle convolved with the other image, the bigger the distortion of the resulting image.

In the third part of the activity we studied correlation.  Correlation is the process of of finding similarities between two signals.  In image processing, the method of correlation is a very powerful tool especially in matching algorithms.


Figure 3: Last column is the correlation of the characters in a phrase in the left column with the letter A in the middle column.

In Fig. 3, we can see the correlation between the image containing a phrase and the letter A.  It can be observed in the resulting image that at the locations of letter A's in the phrase, the correlation value is high.  This implies that the method can be utilized in rough searching of similarities between a template and an image.

In the last part, we performed the method of edge detection using the convolution integral.

Figure 4: Edge detection of patterns in the middle column with the letters VIP.
We can observe here that in Fig. 4, the detection pattern when applied to the original image, the resulting image highlights the edges of the original image.  Also, the detection level vary depending on the detection pattern used.


In this activity I would rate myself 10/10 for the complete results.

Source:
    Activity Sheet for Activity 6 - Dr. Maricor Soriano


Tuesday, July 6, 2010

Entry 11: Enhancement by Histogram Manipulation

Figure 1: RGB image to be used for analysis
Manipulation of pixel value distribution is a method of enhancing image's quality by adjusting the number of pixels having a certain pixel value to a desired distribution defined by the user.

We performed manipulation on the distribution of pixel values of a sample image shown in Fig. 1.

The colored image was first converted into grayscale to assess the value associated for each of the pixels.  The original image shown in Fig. 1 is depicted in grayscale - Fig. 2.

The grayscale version of the original image has its own characteristic pixel value distribution.  We computed the distribution of the pixel value and plotted the histogram of the values.
Figure 2: Grayscale image to be manipulated
In Fig. 3, the histogram of the pixel values in the grayscale image is shown.  The histogram shows that there is a

To start the enhancement of the image, we utilized the method of histogram back projection to reassign the pixels of the image with new values in accordance with the user's specified pixel value distribution.
As shown in Fig. 4, we used a uniform distribution as our target enhancement distribution for the image.  It is displayed in cumulative distribution.
 
Figure 4: Cumulative distribution of the uniform distribution
After applying the method of histogram back projection to the original grayscale image in Fig. 2, the resulting image is shown in Fig. 5.

Figure 5: Enhanced image using pixel values with uniform distribution
Notice that after applying the method to the original grayscale image, the resulting image seems to look brighter and equalized.

The next thing that we did is to investigate the changes in the original grayscale image when it is to be subjected in histogram enhancement using a pseudo-Gaussian distribution of pixel values.

We simulated a pseudo-Gaussian distribution histogram centered at 0.5 and has a spread of 0.2 as its parameters (Fig. 6).

Figure 6: pseudo-Gaussian distribution histogram for image enhancement

The CDF of the histogram in Fig. 6 is shown in Fig.7 which will be essential to perform the necessary image manipulation technique. 

Figure 7: Cumulative distribution of a pseudo-Gaussian distribution (0.5, 0.2)
The resulting image after using the pseudo-Gaussian distribution in the image histogram manipulation is shown in Fig. 8. 

 
Figure 8: Enhanced image using pseudo-Gaussian distribution.
It is quite obvious in the result that the resulting image is depicted by pixel values that are distributed about a central pixel value.  The variation of the intensity across the entire image is less as a result of the histogram used in the back projection method.  The resulting CDF of the enhanced histogram simply follows the histogram of the desired distribution used in the back projection method (Fig. 9).
 
Figure 9: CDF of the enhanced image using the pseudo-Gaussian distribution.
This time around, we used GIMP which is an image editor to manipulate the original grayscale image.  GIMP has a functionality with the same concept as in histogram back projection which is the "adjust color curve".

As seen in Fig. 10, by adjusting the "before-after-intensity curve", the GIMP is capable of changing the pixel value distribution of the input image.

Figure 10: Image manipulation in GIMP using the "adjust color curve"


Now, it must be realized that histogram back projection is a very powerful tool in image processing.  One of the possible applications of the method is when the raw image has a poor lighting, through histogram manipulation it is possible to remedy the problem.


In this activity I would give myself a 10/10 because even I posted this blog late  I was able to make all the necessary results.  Also, the important thing is that I learned a new GIMP functionality. :D