Login  Register

Re: Converting ROIs

Posted by Andy Weller on Aug 04, 2006; 11:33am
URL: http://imagej.273.s1.nabble.com/Converting-ROIs-tp3701905p3701907.html

Hi Gabriel,

I have played with this previously without much luck. It seems that
getSelectionCoordinates(xCoordinates, yCoordinates) just creates a box -
ie, 4 coordinates instead of all of them. This means I go from a
composite selection to a box which I don't want.

Why does getSelectionCoordinates() do this? Can I change it? It'd be
great if it read all the coordinates, making it more flexible.

Thanks, Andy

On Fri, 2006-08-04 at 10:45 +0100, Gabriel Landini wrote:

> On Friday 04 August 2006 10:20, Andy Weller wrote:
> > One thought with this, is it possible to do something like:
> >
> >    run("Create Selection");
> >    select = roi.getType();
> >    select = Roi.POLYLINE;
> > This is probably completely wrong and demonstrating my lack of
> > programming skills (!), but hopefully somebody should know what I am
> > after...?
>
> Have a look in the macro functions. This may help:
> --
> getSelectionCoordinates(xCoordinates, yCoordinates)
> Returns two arrays containing the X and Y coordinates of the points that
> define the current selection. See the SelectionCoordinates macro for an
> example. See also: selectionType, getSelectionBounds.
> --
>
> Then you could recreate a selection based on those coordinates with "type"
> as "polygon" with:
>
> --
> makeSelection(type, xcoord, ycoord)
> Creates a selection from a list of XY coordinates. The first argument should
> be "polygon", "freehand", "polyline", "freeline", "angle" or "point". In
> ImageJ 1.32g or later, it can also be the numeric value returned by
> selectionType. The xcoord and ycoord arguments are numeric arrays that
> contain the X and Y coordinates. See the MakeSelectionDemo macro for
> examples.
> --
>
> If this works, please let me know.
>
> Cheers,
>
> Gabriel