The Mathematics of Extraction

Mapping (Px, Py) to (Dx, Dy)

When an image of a chart is generated, the original data $(x, y)$ is transformed into pixel coordinates $(p_x, p_y)$. Our goal is to reverse this process.

Linear Interpolation

For standard linear axes, we need two reference points on an axis to establish the scale. If we know the pixel locations $P_1, P_2$ and their corresponding data values $D_1, D_2$, the data value $D_x$ for any arbitrary pixel $P_x$ is:

Dx = D1 + (Px - P1) * ((D2 - D1) / (P2 - P1))

Logarithmic Axes

Logarithmic scales compress data exponentially. Linear pixel interpolation will produce massive errors here. Instead, we must interpolate in log-space:

log(Dx) = log(D1) + (Px - P1) * ((log(D2) - log(D1)) / (P2 - P1))
Dx = 10 ^ (log(Dx))

Common Mistake: Rotation Skew

Scanned documents are rarely perfectly aligned. If a chart is rotated by even 1 degree, calculating X and Y independently will introduce cross-talk error. Graphshot applies a full affine transformation matrix to correct for rotation and skew before extraction.