Wednesday, June 16, 2010

First AP186 Activity


In this first activity, we were asked to obtain numerical values of a graph that is manually drawn. For us to do this, we are to use the scanned image of the graph and use its pixel location to be able to find functions that will able to relate the said pixel location to the true value in the graph.

The hand-drawn graph that I chose to reconstruct is a graph that shows a relation foreign salt concentration versus pH of ZnSO4 as shown in the succeeding picture.


Figure 1: Scanned image of a handmade graph.

Maxima and minima pixel location were determined using Paint program. By obtaining these locations, proper scaling methods can be used.

Let us first look at the Y-axis. This axis is pretty much simpler than the X-axis to scale for it explicitly tells us that it has a linear relation. It can simply be related as a starting Y intercept with a value of 3.5pH and as pixels move closer to the top pixel, it linearly approach the value of 6.0pH.

Scaling factor is found by looking at the Y-pixel location of 4.5pH which is 384. As seen, a 1 pH change results to a change of 237 pixel.

The final scaling formula for the pixel to pH relation is:

3.5pH + (no. of pixel * 1pH/237 pixel) = pH

Further modification is that since Paint counts Y pixels from top to bottom(normally it's bottom to top) no. of pixel is modified as:

no. of pixel final = 621- no of pixel

This modification errors of about 15 pixels for I was unable to extract the exact value though this modification is a near approximation on the reconstructed image.

Looking at the X-axis, it can be seen that it is not linear. Scaling formula is that it is exponential that looks like this:

Concentration of foreign salt = (M/4096) * (2^N)
where N is the linear factor of the function.

N here is dependent on the X-axis pixel location of the graph. The total pixel area to be considered in scaling N is equal to 644 pixel- this was from 132 to 776 pixel maxima and minima. There were 12 division considered so N can be obtained as:

N = (12/644 pixel) * (pixel location)

By establishing these relations, I can simply plug-in the coordinates of the X and Y pixels and the natural value can be obtained. This is where Microsoft Excel and Office Office Spreadsheets comes in handy. I plugged in the relations and the coordinates and was able to obtain values. Sample calculations are shown below:

Figure 2: Sample Calculations of Natural values from Scanned Graph

Graph was fitted in terms of N for it is the linear scale for the graph. If it be the natural value of the Concentration, graph may have the same form but will have wider and more compact sections of the graph.

Fitted and overlayed graphs are shown here:

Figure 3: Fitted and overlayed graph of the scanned and the reconstructed.

It can be seen that the reconstructed part considered was from the M/4096 to M/4. It is because I am unable to relate M/4096 to 0 generally with the M/4096 to M/4.

I'd say I think out of 10, I'd grade myself 10 for I was able to reconstruct the image using the methodologies and utilities needed.

I'd like to thank Maam Jing for helping me with scaling the x axis, Aivin for helping me figure out Open Office because there was a time a while ago that I was really freaking out because I can't format the spreadsheet's cells and Jane for lending me her laptop for my laptop is crappy and broken.

Thanks for reading. This is one of the times that I will post seriously. LOL

1 comment:

  1. FOR Errors, kindly comment here. It is appreciated . :)

    ReplyDelete