0

Given a graph of a formula, how can I find its formula?

Do I need some OCR or something like that?

Am_I_Helpful
  • 18,735
  • 7
  • 49
  • 73
  • 2
    Google *curve fitting*. – aioobe Nov 15 '15 at 09:44
  • In the general case, the answer is too broad. You would be better off asking on [math.se] — and be sure to include some details in your question. [Example](http://math.stackexchange.com/q/751127/77144). – 200_success Nov 15 '15 at 10:05
  • @200_success I do not agree with that "he would be better off asking on Mathematics" because this is clearly DIP/CV and curve fitting task. Pure Math guys have usually no clue about such things – Spektre Nov 15 '15 at 14:15
  • Why OCR? That would be applicable only if you got the formula inisde the input image. But in other hand the scales mut be known so you can use it for that Add example input of graph you want to convert ...programming Language and some more details ... like needed accuracy, dimension count (assuming 1D functions or 2D curves) – Spektre Nov 15 '15 at 14:17
  • 2
    Note that curve fitting may give you *a* formula, but it would not necessarily be the exact formula that was used to create the graph. – Jongware Nov 15 '15 at 14:22

1 Answers1

1

In general you need:

  1. detect the graph position (bounding box) in image

    you are usually looking for rectangle outlined (usually in black) area

  2. extract/input graph scales

    either input them by user or read via OCR (as you suggested). The scale values and units are usually along the x,y axises of the graph bounding box. You need to find at least 2 separate points per axis to form transformation from pixels to units. In case of non linear scales you need to have more points to detect log,etc scales ...

  3. extract graph points

    the graph curve is usually in different color or stroke width so it should be relatively easy to extract all points. Form a list of points (in case of function sorted by x).

  4. apply curve fitting on the points from #3

    there are many approaches ... can use piecewise interpolation, piecewise approximation BEZIER/SPLINE, interpolation polynomials (Lagrange...) or FFT/DCT (sin waves). For non complicated shapes approximation search minimizing distance between points and computed polynomial will be enough. This step mainly depends on what precision, output function form, runtime you need.

Hard to be more specific as you did not provide any details what so ever.

Finding the mathematical algorithm to which matches an input and output together might help a bit.

Community
  • 1
  • 1
Spektre
  • 49,595
  • 11
  • 110
  • 380