Can someone please tell me the formula used to fit the piecewise curve to the control points:

Are they cubic? quadratic?

—

Open Source: Beast, LayerEffects, VFLib, SimpleDJ, DSP Filters...

Fri, 10 Aug 2012 - 23:45

#1
Name that spline!

Can someone please tell me the formula used to fit the piecewise curve to the control points:

Are they cubic? quadratic?

—

Open Source: Beast, LayerEffects, VFLib, SimpleDJ, DSP Filters...

© 2014 Raw Material Software Ltd.

You can achieve this through cubic or quadratic interpolation. The only problem is that these interpolations tend to swing around the points and thus create overshoots which might cross the boundaries of the box. Hence there are special modifications of these interpolations which get rid of the overshoots.

zamrate wrote:Well when you bring control points close together, the local minima/maxima quickly go outside the box. Photoshop handles this by just clamping the output to [0, ]1

Open Source: Beast, LayerEffects, VFLib, SimpleDJ, DSP Filters...

zamrate wrote:Yep, I think that's the answer. I found this interesting Javascript applet:

http://www.benjoffe.com/code/demos/interpolate/

The behavior of the control points in Photoshop's "Contour" dialog is exactly like in this applet. The Javascript applet is doing simple Newton form polynomial interpolation through N points (up to degree 10). So, to replicate this functionality I would only need implement N degree polynomial interpolation (Numerical Recipes has a few of these).

By marking a control point as a "corner" it breaks the polynomial in half, piecewise, into two smaller degree polynomials passing through the left and right set of points, with 1 point shared (the corner point). Two adjacent corner points implement a straight line piece.

Open Source: Beast, LayerEffects, VFLib, SimpleDJ, DSP Filters...