Login  Register

Access 3D positions from ROI Manager

Posted by Michael Doube on Aug 29, 2008; 10:50am
URL: http://imagej.273.s1.nabble.com/Access-3D-positions-from-ROI-Manager-tp3695210.html

Hello

I'm writing a plugin that would benefit from having access to 3D
coordinate data from point selections listed in the ROI manager,  but
I'm having trouble getting access to them - in particular the Z coordinates.

getSliceNumber() looks like a useful method but it expects a String
index, which I don't know how to retrieve.  This is what I have so far:

Mike

public class Fit_Sphere implements PlugInFilter {
        ImagePlus imp;
        RoiManager roiMan = RoiManager.getInstance();
               
        public int setup(String arg, ImagePlus imp) {
            this.imp = imp;
            return DOES_ALL + STACK_REQUIRED;
        }
       
        public void run(ImageProcessor ip) {
                if (roiMan.getCount() < 5) IJ.error("ROI Manager contains < 5 ROIs");
                double xSum = 0, ySum = 0, zSum = 0;
                Roi[] roiArray = roiMan.getRoisAsArray();
                Hashtable roiHash = roiMan.getROIs();
                List listRoi = roiMan.getList();
                for (int i = 0; i<roiMan.getCount(); i++){
                        Roi roi = roiArray[i];
                        IJ.log("Roi "+i+" contains: "+roiArray[i]+" which has integer
typecode "+roi.getType());
                        if (roi.getType() == 10){
                                 Rectangle xy = roi.getBoundingRect();
                                 xSum += xy.getX();
                                 ySum += xy.getY();
                                 zSum +=  //???
                        }
                }