The goal of this activity is to extract a hand-drawn (or X-Y plotter) graph from an "ancient" journal.
From the scanned image, the graph equation will be estimated to be used in reconstructing the graph numerically.
For this activity I used a plot from Dr. Caesar Saloma's 1986 Ph.D. dissertation paper.
Fig 1. Original scan
I rotated the image in GIMP, taking advantage of the guide tools to make sure that the x- and y- axes are as horizontal and vertical as possible.From the extracted graph i randomly picked several points (got 82). Instead of manually noting down the pixel coordinates of the selected points, i drew over them on a separate layer. I loaded the new image in Python, converted it into a matrix and saved the pixel coordinates from that.
Fig 2. Extracting data points
From the extracted points, I used numpy polyfit to obtain an equation of the curve. Why polyfit? Because I have no idea what form the equation might be like and polynomial fitting is like cheating when estimating equations. It doesn't fit? Just add more terms. EZ GAME.

Fig 3. First result using 5th degree polynomial
At first I did not know how to deal with the logarithmic y-axis so I left it as is. The scaling of the x-axis turned out to be pretty good where 155 x-pixels = 1 micrometer. I observed that a 5th order polynomial looks close enough and is actually better than having a 6th term.
After 2 hours of manually adjusting my parameters, I finally got a decent looking semilog reconstruction.
Fig 4. Final reconstruction using 10th degree polynomial.
I actually used a 10-term polynomial to fit this which I feel is way beyond cheating. I really have no idea how to deal with logscale axes.
What I did:
- normalized y.
- converted y to magnitudes via y = 10^(ypix/ky); where ky is the number of ypixels between 1 magnitude. I used 130 pixels.
- renormalized the converted values.
- multiplied by 12 (because i think the highest value is around 12 -- definitely above 10)
- subtracted a constant value such that the lowest value is 0.25 (which i think is the start of the x axis)
Welp close enough.
Tools used:
- GIMP for image conditioning(?)
- Python 2.7 with scipy.ndimage and numpy
- Microsoft Excel for plotting
- Garena Plus Messenger -- my favorite screen shot tool that lets you highlight/draw on the spot (plus most of my friends that I want to talk to are online here. Who needs facebook.)
Sige advertise pa.
Pabonus:
Fig 5. To overlay (backgroundlay? derp) image in Excel
Nuff said.
Self evaluation
- Technical correctness - 4 (close enough but dem logscale)
- Quality of presentation - 3 (It's 5:40 and I still have to blog activity 3. Goodluck)
- Inititative - 1 (Bonus pls)
- Total - 8
No comments:
Post a Comment