Name that spline!

4 posts / 0 new
Last post
TheVinn
Offline
Last seen: 3 weeks 3 days ago
Joined: 29 Aug 2009 - 11:31
Name that spline!

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

Are they cubic? quadratic?

zamrate
Offline
Last seen: 1 year 2 months ago
Joined: 24 Sep 2007 - 17:33
Re: Name that spline!

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.

TheVinn
Offline
Last seen: 3 weeks 3 days ago
Joined: 29 Aug 2009 - 11:31
Re: Name that spline!

zamrate wrote:
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.

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

TheVinn
Offline
Last seen: 3 weeks 3 days ago
Joined: 29 Aug 2009 - 11:31
Re: Name that spline!

zamrate wrote:
You can achieve this through cubic or quadratic interpolation.

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.