Suggestion: Get Spline anchors

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Suggestion: Get Spline anchors

vischer
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.

Norbert
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Suggestion: Get Spline anchors

Rasband, Wayne (NIH/NIMH) [E]
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