Posted by
Jerome Mutterer-3 on
URL: http://imagej.273.s1.nabble.com/Macro-code-to-fit-a-spline-to-two-segments-tp5009069p5009350.html
Dear Olivier,
You could create the ABC polyline, fit a spline to it and measure its
length:
open("
http://imagej.1557.x6.nabble.com/file/n5009069/geometry.png");
makeLine(203,212,449,320,872,427);
run("Properties... ", "stroke=cyan");
roiManager('add');
run("Fit Spline");
run("Properties... ", "stroke=blue");
roiManager('add');
List.setMeasurements;
length = List.getValue('Length');
print (length);
setOption('show all', true);
Jerome.
On 26 August 2014 12:01, Gabriel Landini <
[hidden email]> wrote:
> 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>
--
Jerome Mutterer
CNRS - Institut de biologie moléculaire des plantes
12, rue du Général Zimmer
67084 Strasbourg Cedex
T 0367155339
www.ibmp.cnrs.fr
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html