Calculates the derivative of a graph from a given image. Check out an interactive demo here.
Note: it may take a few moments to initally load the app.
The scripts folder contains the two algorithms currently used by Derivify. Calling the derivify_bezier or derivify_least_squares functions with arguments (input_filepath, output_filepath)
saves a derivative graph for the specified file to the designated output path. Currently, only black and white images (PNG, JPG, BMP) are supported.
Alternatively, you can deploy the flask application with flask run
in the website folder.
Note: The graph should be continuous.
- Bezier Curves: The first algorithm uses potrace to convert the given image to SVG format, consisting of multiple Bézier curves joined together. Afterward, the derivative (
dy/dx
) for each curve is calculated and plotted on a new graph. Since the resulting curves can have unwanted sudden spikes in values, the algorithm applies a Savitzky–Golay filter to smoothen the data. - Least Squares Polynomial: The second algorithm relies on a more straightforward approach – it first examines the pixels of the image and determines the average y-value for every x-coordinate. For every window of ~50 x-coordinates, the algorithm computes the best fit cubic polynomial and calculates the resulting derivative. Finally, it joins these results together to produce an overall graph of the derivative function.
See examples.
pip install -r requirements.txt
and potrace.
- Make the svg parser more robust
- Support PNG and JPG images
- Smooth out the resulting derivative graph
- Create a simple website that runs Derivify on uploaded images
- Host the flask app
- Create a canvas for users to directly draw graphs
- Substitute Bezier curves with polynomials using least squares
- Include a similar antiderivative functionality
- Allow users to adjust parameters for the derivify functions