Thursday, June 17, 2010

First Blog Ever : Activity 1 AP 186

Yehey! My first blog ever!

This blog is about our first activity in my AP 186 class. In this activity, we are asked to numerically reproduce a scanned image of a hand-drawn graph. To do this, we must utilize ratio and proportion.

For the graph, my classmates and I went to the CS library to find old journals. Then, we searched for hand-drawn graphs and photocopied it. I got my graph from the journal below. Thanks Dennis Ivan Diaz for finding this journal and sharing it with us. :)

The Photographic Processes in Spectrum Analysis by B. H. Carroll
Applied Spectroscopy, Vol. 1, Issue 4, pp. 1-15
(1946)



Figure 1. Scanned image of the hand-drawn graph.

After scanning the graph, I edited it using GIMP 2.6.6 because it was tilted a little. After correcting it, I then used Paint to crop the image. I retained only the graph itself and removed the labels and texts.


Figure 2. Cropped image of the hand-drawn graph.

The first thing I have done is to get all the pixel locations of the points in the graph. I took many points for better data representation. After that, I took the scaling factor for the x and y coordinates. I took the maximum value of x and y in the graph and their corresponding pixel locations. I used the formula,

X(pixel location of xmax, ymax)=value in the graph Equation [1]

where X is the scaling factor. For the y values of the data points, I inverted the values of the pixel locations. Since the highest position of the pixel in the y axis corresponds to zero, I interpolated values for each point in the graph based on the inverted values of the pixel locations. Then, I just multiplied the scaling factor to the pixel locations. The value of xmax is 235 and its corresponding value is 120. For ymax, the value is 269 and the point in the graph is 70. The scaling term for x is 0.5106, and for y the value is 0.2602 Then, I plotted the points and superimposed it to the hand-drawn graph. This is what I got:

Figure 3. Superposition of the obtained numerical values and

the image of the hand-drawn graph.


Notice that the tick marks on the graph do not correspond to the hand-drawn graph!!!! Oh no! What went wrong?

I consulted Ma'am Jing and showed her my graph. She said that maybe the error is due to the missing bias term in the equation I used. Notice that the X in the equation is like a slope of a line. Since the points on the graph is linearly proportional to the pixel locations, the equation must be of a straight line, given by the formula:

y = mx + b Equation [2]

where y is the true value on the graph, x is the pixel location, and b is the biasing term. To get this equation, I obtained the corresponding pixel locations of the tick marks and plotted it against their true value. Then, I linear fitted the points and obtained the equation of the fitted line. The R squared value of the graphs is equal to 1, which means that the fit is very good. Then, I used the equation of the fitted line to scale the values of the pixel locations. The equations I got were the following:

y = 0.126x + 400.1 Equation [3]

y = -0.065x + 70.4 Equation [4]

where equation 3 used to scale the x pixel locations and equation 4 to scale the y pixel locations. Then, I superimposed the graph again to the hand-drawn graph. Now, this is the result:

Figure 4. Superposition of the obtained numerical values and

the image of the hand-drawn graph

using equation 3 and 4.


Notice that the tick marks have better correspondence compared to before. Yehey!

I would like to thank Joseph Raphael Bunao for scanning the photocopied hand-drawn graph and for the useful discussions about the activity. Also for Ma'am Jing for pointing out the error.

I would give myself a score of 9/10 because the tick marks are still not perfectly aligned. Maybe the deviation is because the image of the hand-drawn graph is still tilted a little.

score: 9/10



No comments:

Post a Comment