One Example cost function
f is the angle between the gradient at p(j-1) and
p(j).
Or it
could more directly measure curvature of the curve.
(Loosely based on “Dynamic Programming
for Detecting, Tracking, and Matching Deformable Contours”, by Geiger, Gupta, Costa, and Vlontzos, IEEE Trans. PAMI
17(3)294-302, 1995.)