Our first step toward curve-based filters is to convert control points into a function. Most of this work is done for us by a SciPy function called scipy.interp1d, which takes two arrays (x and y coordinates) and returns a function that interpolates the points. As an optional argument to scipy.interp1d, we may specify the kind interpolation; supported options include 'linear', 'nearest', 'zero', 'slinear' (spherical linear), 'quadratic', and 'cubic'. Another optional argument, bounds_error, may be set to False to permit extrapolation as well as interpolation.
Let's edit the utils.py script that we use with our Cameo demo and add a function that wraps scipy.interp1d with a slightly simpler interface:
def createCurveFunc(points):
"""Return a function derived from control points...