Tuesday, June 22, 2010

AP 186 Activity 1: Digital Scanning

*Transferred from Facebook notes to here*

This blog is for one of our major subjects: Applied Physics 186 which requires us to write blog reports about our activity. So if you're reading this to find out what my favorite food is or what crazy things I did today, you're not gonna find it. =p

So let's start:

Activity 1 - Digital Scanning


Basically the objective of this activity is to get any hand-drawn graph from any journal article (which means the journal has to be old, since they use computers to graph nowadays), scan it, then reproduce the graph in Microsoft Excel using ratio and proportion of the pixels and their corresponding physical value. We get bonus points if we are able to overlap the two graphs together for a better comparison.

I found this nice looking graph in the CS lib from the article:

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

I chose the graph because:
  1. It's big.
  2. It's smooth.
  3. It's not in log scale and
  4. It has two curves in it. :)

I don't have a scanner so I asked my friend Millicent Singson to scan it for me. (Thank you!) The scanned picture has the dimensions 1700 x 2200 pixels.


The picture is a bit tilted so I used Adobe Photoshop to rotate it.

In order to reproduce the graph, I have to find an equation relating pixel location to physical values. So for the x and y axes, I got the pixel location of the start and end values of axes. Then the "multiplier" would be:

(End value - Start value)/(End Pixel - Start Pixel)

which we will denote as Mx and My for the x and y axis repectively.

Then you just have to multiply this to the pixel location and you would get the value. However, since i didn't crop the picture before i started counting the pixels, the pixel locations would not start at 0. Therefore I would have to subtract this "pixel offset" first before multiplying it with the above equation.

Another problem is that the origin (0, 0) doesn't start at the bottom left corner but rather at the top left corner. But this can be easily solved. :)

Another thing to keep in mind is to add the initial starting value of the axis after you convert from pixel to value. In this case, I added 200 to the values in the x axis.

So the equation is:

(x pixel location - x pixel offset) * Mx + x value offset

for the x axis and

(y pixel location - y pixel offset) * My + y value offset

for the y axis

I got plenty of sample points (17 for the blue curve and 20 for the red curve) and reconstructed it. After overlaying the image with the graph, there's a discrepancy between the tick marks of the two. Eventually I found out that the value "4" on the y-axis isn't really 4 so I used 3 instead. Computations are as follows:

For the x-axis:

End value = 400
Start value = 200

End Pixel = 1466
Start Pixel = 174

value offset = 200
pixel offset = 174

and Mx is computed to be 0.1548

Then the equation would be:

(x pixel location - 174) * 0.1548 + 200

For the y-axis:

End value = 3
Start value = 0

End Pixel = 293
Start Pixel = 1305

value offset = 3
pixel offset = 293

and My is computed to be - 0.00296

Then the equation would be:

(y pixel location - 293) * (- 0.00296) + 3

The negative sign of My and 3 being the value offset is because the origin starts at the top left corner.

So now I just have to plug in the x and y pixel locations of the sample points.

Finally, the result (*whew*):


The blue and red curves are the reconstruction and they show good agreement with the original graph; Swak.
If you look closer there's a little difference in the first tick mark which is due to the graph being hand-drawn. :)

Grading myself, I'd give it a 10/10 for being able to accurately reconstruct the graph with captions and another 2 bonus points for being able to overlay the image onto the graph. :) So that makes it:

Score: 12/10

Finally I would like to thank Dr. Soriano in helping me troubleshoot and Millicent Singson for scanning the graph for me. :)

- Dennis

References:
1. M. Soriano, "A1 - Digital Scanning"

No comments:

Post a Comment