Re: geometric challenge :)

Posted by Gabriel Landini on
URL: http://imagej.273.s1.nabble.com/Macro-code-to-fit-a-spline-to-two-segments-tp5009069p5009347.html

On Tuesday 26 Aug 2014 09:14:09 Leon Espinosa wrote:
> Dear Olivier, yes indeed if you vave the image coordinates ofA B and C you
> have :
>
> AB^2 = (xB-xA)^2+(yB-yA)^2
> also:
[...]
I think Olivier wants the spline length (in green) not the polyline (in red).

I do not think that one can obtain this analytically unless you know what type
of spline it is (i.e. what is the function used to generate the green line).
Once you know the function perhaps you can use calculus to find the function
length.
http://en.wikipedia.org/wiki/Arc_length

If you try to measure the chain of pixels forming the green line you will get
an overestimation of the length as the curves on screen are constructed in
steps of 1 or sqrt(2). (By the way, this is the reason why we do not get 1.0
as Circularity of a discrete circle; the perimeter estimation ends up longer
than it is for a perfect circle).

By using a spline interpolation, you are making already assumptions about
the points being appropriately fitted by such spline and that the original
data is differentiable (for example at a higher magnification the spline might
not fit the data at all; think of a fractal curve). Unless you know that those
assumptions are correct, perhaps Leon's approach (estimating the length of the
polyline) at a particular resolution might be better (and specify the
resolution when you report the length).

Cheers

Gabriel

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html