Re: Access 3D positions from ROI Manager
Posted by
Michael Doube on
Aug 29, 2008; 5:12pm
URL: http://imagej.273.s1.nabble.com/Access-3D-positions-from-ROI-Manager-tp3695210p3695211.html
I found a solution, which is in a sphere-fitting plugin just ported
(from C++) and published here:
http://doube.org/plugins.html#fitsphereMike
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