Re: ROI type and ROI Manager
Posted by selwyn on Aug 02, 2008; 10:18pm
URL: http://imagej.273.s1.nabble.com/ROI-type-and-ROI-Manager-tp3695459p3695462.html
William O'Connell wrote:
> Dear listers,
>
> I have a plugin which fits edges to objects in a stack of images. The edge
> points are saved as PolygonRois(type 2) in an RoiManager. I retrieve the
> ROIs in another Plugin with the getRoisAsArray() command. But the ROIs are
> now type 4, TRACE_ROIs. I want to retrieve the coordinate points, but the
> getXCoordinates() and getYCoordinates() are not supported.
> I welcome any suggestions.
> Bill O'Connell
You might be able to use the following piece of javascript I adapted
from ListPixelsinROI.js found under the Macros examples at the ImageJ
website.
Selwyn
// List Perimeter Pixels In ROI
//
// Displays the coordinates and values of
// the pixels within a non-rectangular ROI.
//
var img = IJ.getImage();
var roi = img.getRoi();
var mask = roi!=null?roi.getMask():null;
if (mask==null)
IJ.error("Non-rectangular ROI required");
var ip = img.getProcessor();
var r = roi.getBounds();
var z = img.getCurrentSlice()-1;
var toggle = 0;
for (var y=0; y<r.height; y++) {
for (var x=0; x<r.width; x++) {
if (mask.getPixel(x,y)!=toggle) {
toggle = (toggle == 0) ? 255 : 0;
IJ.log(x+" \t"+y+" \t"+z+" \t"+ip.getPixel(r.x+x,r.y+y));
}
}
}