Tuesday, June 30, 2009

Activity 4: Enhancement by Histogram Manipulation

In this activity we were able to enhance images through histogram manipulation. The steps in doing this are as as follows:

1. The normalized histogram of the image is determined. This was done with the help of the find command in Scilab.
2. From the obtained counts per grayscale value, the cumulative distribution probability (CDF) of the image is also determined.
3. A desired CDF is plotted. This is user-defined but for the purpose of this activity linear and logarithmic CDF were used.
4. Pixel per pixel, the grayscale values of the image are replaced by the corresponding grayscale value of the desired CDF with y values equal to the y values of the image's CDF. This is illustrated by figure 1.


This is the original image that was enhanced.

www.crestock.com/uploads/blog/b%26w-tutorial/street-havana-grayscale.jpg

Image Histogram

From the obtained image histogram, it was seen that the minimum grayscale value is 5 while the maximum is 255.
CDF

The figure shows the obtained normalized CDF. As can be observed from the figure the CDF is increasing. However it's increase is not linear.

The image above shows the desired CDF which is a linear plot ranging from 0 to 1. Using this desired CDF, backprojection is implemented and resulted to the enhanced image.The histogram and CDF of this enhanced image is as follows. Applying histogram equalization resulted to a more contrast image. It can be observed when the histogram of the enhanced image is compared to that of the original that the histogram of the enhanced is a strecthed version of the original. As can be seen the length of the grayscale values where peaks occured widened. This is in accordance to the desired CDF. In addition, it can be observed that the calculated CDF for the enhanced image follows the plot of the desired CDF. This is expected since backprojection is a pixel per pixel mapping of CDFs.

This same process were applied to the image below.


original image
http://gallery.photo.net/photo/5476781-md.jpgenhanced image

The shown enhancements are for linear CDF. The human eye however has a non-linear response and is similar to a logarithmic plot. Using logarithmic plot as the desired CDF resulted to the following enhanced images.As can be seen the enhanced images of a desired logarithmic CDF became darker as compared to that of the original.

For this activity I give myself a grade of 9 for I was able to enhance the images through histogram manipulation.

I thank Cherry Palomero, Irene Crisologo and Jaziel Vitug for discussing the activity with me.













Wednesday, June 24, 2009

Activity 2: Area estimation for Images with defined edges

For this activity the area of binary images are estimated. This was done using Green's theorem that relates a double integral to a line integral. This is given by the following equation;

Using this equation it can be found that the area of an enclosed region is given by the following equation in discrete form;
Using this formula, the area of various generated shapes were estimated using scilab 4.1.2 with a SIP toolbox. Here are the shapes whose areas where estimated.

square

circle

triangle

The estimated and analytical values of the areas are shown in the following table. The analytical value of the area for each shape is calculated using pixel counting.
The errors in the estimated area came from the offset in the detected contour of the follow command in scilab. The 'true' contours of some corners of the shape were not detected accurately. Hence it resulted to the error in the estimated area.

For this activity, I'll give myself a grade of 9.5. This is because I was able to estimate the area of various generated shapes with a small percent error.

I thank Mimie Balgos for teaching me how to install the SIP toolbox.

Monday, June 22, 2009

Activity 3: Image types and basic image enhancement

Shown are different types of images copied from the web.


Binary Image

Grayscale

True Color

Indexed Image

This activity is similar to the previous one. Again the area of a given image is to be calculated. The scanned image for this activity is show below.


The image above has a dimension of 781 X 445 and was saved in a jpeg format. It was converted into grayscale; hence 256 colors are only present.

The histogram of this image was calculated using the follow function in Scilab. Here is the snippet used.

//histogram
for i=0:255
x = find(im==i);// im is the image used
count(i+1) = sum(x);

end

scf();plot(0:255,count)


Using this code, the histogram of the image was calculated and is shown below.

Recall that in a grayscale image black is zero and white is 255. The histogram clearly shows that the object(the name kaye) which is color white is well separated from its background.

Afterwards the grayscaled image is binarized using the threshold point obtained from the histogram of the image and the function im2bw. In thresholding, a point separating the object from its background is used to map points greater than or equal to it to 1 (white) while points less than it to 0 (black).

After binarization, the same steps in area identification was done. For the shown image, the calculated area of the object (name kaye) was 131142.5 pixels. This was compared to the measured area through pixel count which was equal to 133220 and was found to have a 1.6% error.

The same process was also done for the figure below.


http://en.wikipedia.org/wiki/Coins_of_the_Philippine_peso

After binarizing the image using thresholding..


The area of this one peso coin was calculated and was compared to its analytically computed area. The calculated area was found to deviate 1.3% from the original value.


For this activity, I'll give myself a grade of 10 for I was able to calculate the area with only a 1.6% and 1.3% error for the scanned and one peso coin images, respectively. Also, I'm giving myself a two point bonus since I was able to make a code that computes and plots the histogram of an image.

I thank Miguel Sison, Jica Monsanto, Jay Samuel Combinido and Mark Jason Villangca for the KAYE-image used.

Wednesday, June 17, 2009

Activity 1 - Digital Scanning

For our first activity, we digitally replicated a graph coming from an old book. The graph that I was able to get is from the book X rays in Theory and Experiments that was published in 1935.

Here are the steps that I used in reconstructing the graph:
1. Open the scanned graph using paint.
2. Obtain the pixel values of points in the graph by placing the pointer in the designated points.
3. The origin of the image and the reconstructed graph must coincide (the origin in an image is found at upper left corner of the image). This is done by getting the absolute value of the difference of the origin's pixel value and any other points' pixel values.
4. Tabulate the measured pixel values using Excel or OpenOffice Spreadsheet.
5. By using ratio and proportion, obtain the equation relating the physical values to the pixel values and use this to interpolate points on the graph.
6. Reconstruct the graph in Excel or Spreadsheet.
7. Compare the generated and the scanned graph by overlaying the two.

Here are the results obtained.

The table above shows the pixel values (Pixel along X and Y) corresponding to the the physical values.

The figure above shows the scanned and the reconstructed graph. As one can observe there is an offset. Some points of the reconstruction are relatively far from its corresponding points on the scanned graph. This maybe because of the angled x-axis of the scanned image. I actually rotated the image in such a way that the y-axis would be vertical. However when I did that, it resulted to the angled x-axis. When I checked the hardcopy of the image, the x-axis of the graph is really tilted.

For this activity, I will give myself a grade of 9. This is because I was able to reconstruct the graph similar to that of the original although there is a slight offset.

I thank Janno Vergara for teaching me how to overlay images on a spreadsheet graph and also the College of Science Library where the book X rays in Theory and Experiments can be found.