Access 3D positions from ROI Manager

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

Access 3D positions from ROI Manager

Michael Doube
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 +=  //???
                        }
                }
Reply | Threaded
Open this post in threaded view
|

Re: Access 3D positions from ROI Manager

Michael Doube
I found a solution, which is in a sphere-fitting plugin just ported
(from C++) and published here:

http://doube.org/plugins.html#fitsphere

Mike

Michael Doube wrote:

> 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 +=  //???
>             }
>         }
>
>
>

--
Dr Michael Doube  BPhil BVSc PhD MRCVS
Research Associate
Department of Bioengineering
Imperial College London
South Kensington Campus
London  SW7 2AZ
United Kingdom