Login  Register

Re: Suggestion: Get Spline anchors

Posted by Rasband, Wayne (NIH/NIMH) [E] on Jan 31, 2015; 5:46am
URL: http://imagej.273.s1.nabble.com/Suggestion-Get-Spline-anchors-tp5011346p5011392.html

On Jan 28, 2015, at 6:40 AM, Norbert Vischer <[hidden email]> wrote:

>
> The macro below creates a smoothed segmented line, using the 4 points as anchors (or handles).
>
> makeLine(76,222,150,70,357,179,419,146);
> run("Fit Spline");
>
> After editing the anchor points, I cannot retrieve them anymore.
> As there is no "Unspline" command, it would be useful if there were commands like:
>
> Roi.getAnchors(xx, yy)
> Roi.setAnchors(xx, yy)
>
> Then not only the mouse, but also a macro could read and move the handles. And the path could be stored in a much shorter array.

The latest ImageJ daily build (1.49p7) adds three macro functions:

  Roi.setPolylineSplineAnchors(x,y),
  Roi.setPolygonSplineAnchors(x,y)
  Roi.getSplineAnchors(x,y)

And the following macro demonstrates their use.

-wayne

 requires("1.49p");
 newImage("Untitled", "8-bit ramp", 500, 500, 1);
 x = newArray(76,150,250, 419);
 y = newArray(222,70, 179, 120);
 for (i=0; i<250; i++) {
    x[3] -= 1;
    y[3] += 1;
    Roi.setPolylineSplineAnchors(x, y);
    wait(25);
 }
 for (i=0; i<250; i++) {
    x[3] += 1;
    y[3] -= 1;
    Roi.setPolygonSplineAnchors(x, y);
    wait(25);
 }
 Roi.getSplineAnchors(xx, yy)
 for (i=0; i<x.length; i++)
    print(xx[i]+","+yy[i]);

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