ROI XY coordinates

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

ROI XY coordinates

Eric BADEL-2
I need the list of ALL the coordinates and all the corresponding grey values
of an ROI. (This ROI is a boundary).
- Save As \ Coordinate XY does not work for this because it gives only the
extremities of boundaries segments (when they are vertical or horizontal).
So, few data are missing.

- getSelectionCoordinates(x, y); does not work too for the same reason.

Is there a way to get ALL the coordinates of an ROI (boundaries or area ROI) ?
Thank you
Eric
Reply | Threaded
Open this post in threaded view
|

Re: ROI XY coordinates

Eric BADEL-2
    This does not work. Some of the cell are in the ROI and some of them
    are outside.
    I tried with the following test and I got values=0 or 255. This mean
    the fit curve goes throught the boundary. looks bizarre...

    labels = newArray(3);
    labels[0] = "X";
    labels[1] = "Y";
    labels[2] = "values";
    run("Fit Spline", "straighten");
       getSelectionCoordinates(x, y);
       for (i=1; i<x.length; i++) {
           value =getPixel(x[i-1],y[i-1]);
           setResult(labels[0], i, x[i-1]);
           setResult(labels[1], i, y[i-1]);
           setResult(labels[2], i, value);
       }
    updateResults();

    ****************************************
    I need the list of ALL the coordinates and all the corresponding
    grey values
    of an ROI. (This ROI is a boundary).
    - Save As \ Coordinate XY does not work for this because it gives
    only the
    extremities of boundaries segments (when they are vertical or
    horizontal).
    So, few data are missing.

    - getSelectionCoordinates(x, y); does not work too for the same reason.

    Is there a way to get ALL the coordinates of an ROI (boundaries or
    area ROI) ?
    Thank you
    Eric

------------------------------------------------------------------------
You can often find answers to these questions by searching the ImageJ
archives.  :-)


------------------------------------------------------------------------
On Sep 24, 2008, at 6:29 AM, Adam Cliffe wrote:

>  Does anyone have a macro which will list all of the coordinates for an
>  ROI?
>  (not just the ends of the vertices)

One way to do this is to run the Edit>Selection>Fit Spline command with
the "straighten" option, which is what the Edit>Selection>Straighten
command does to get coordinates along a line spaced one pixel apart.
Here is an example:

   requires("1.41i");
   run("Fit Spline", "straighten");
   getSelectionCoordinates(x, y);
   for (i=1; i<x.length; i++) {
       distance =
sqrt((x[i]-x[i-1])*(x[i]-x[i-1])+(y[i]-y[i-1])*(y[i]-y[i-1]));
       print(i, x[i], y[i], distance);
   }

-wayne