# OCR: some App to calculate the derivative on a line graph with iPhone/iPad?

Problem

I have a set of points like the ones shown on the right hand side of the image. So for each 'Ships Head' there is a corresponding value for 'Deviation'. In this example we can treat west as negative and east as positive values.

On the left of the image there is a graph made from the points on the right. What I need to do is find a way of using a setup like this to work out the deviation for any given point on the graph. So for example, given the value of 10 degrees, we should be able to calculate the deviation as something around 3.8 degrees.

Obviously its easy to manually draw a graph and then read off values however I need a way of doing this in code. I have never had to solve a problem like this before and I don't know where to start. I was thinking I could make use of trigonometry and maybe some sort of cosine wave but i don't know how to do this.

What is the way of calculating the deviation for a given degree value based on the values on the right hand side of the image?

-

## migrated from stackoverflow.comJun 27 '12 at 14:40

This question came from our site for professional and enthusiast programmers.

Are you asking how to calculate a derivative? – Cake Jun 27 '12 at 14:03
Welcome to math.SE. Do you mean you'd like to perform a regression on the given table of values? – user2468 Jun 27 '12 at 15:38

It looks like a sine wave, so I would just use Deviation (deg E) = $6 \cos (heading - 135^\circ )$.

-

I suggest using a digitizing software to convert the graph into numbers. Once you have the graph as a data file, you can use whatever fitting algorithm you wish (usually a least square estimator provides good results).

For the digitizing software, I use im2graph. im2graph is free and available for Linux and Windows. Converting graphs to data requires very little effort on your part. Simply select the graph and then export it to data either as a CSV file (which is basically a text file with commas) or copy it to the clipboard and paste to Excel or the like.

For more details see http://www.im2graph.co.il ; There are plenty of videos to explain the process.

-

I understand your want as a procedure below. There are different options for it, I cover both scenarios below.

Procedure

1. shoot photo from the picture

2. you move your finger along the graph where the program tells you the derivative along the curve

Options

1. if you have some software, it may have OCR -capabilities to do this but now no mention about the software

2. try to find out some OCR -software which calculates the derivation along the curve

I haven't yet found anything like this, perhaps such software will emerge after this feature-request and app-request. DocScan -app basically has similar technology to do this but meant for storing notes, not for analyzing photos and certain details about it. I am still investigating whether some math -software with OCR -capabilities exist.

You can find here a similar question but for formulae, not for graphs -- anyway the same problems with cluster-analysis, feature-extraction, feature-selection, image-processing, pre-processingg and decision-making.

-