Given a graph of a formula, how can I find its formula?
Do I need some OCR or something like that?
Given a graph of a formula, how can I find its formula?
Do I need some OCR or something like that?
In general you need:
detect the graph position (bounding box) in image
you are usually looking for rectangle outlined (usually in black) area
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 ...
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).
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.