Quantcast

Getting XY coordinates for a plugin

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
kt7
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Getting XY coordinates for a plugin

kt7
Hi all,
Stumped again so I am trying to get the coordinates enclosed by a ROI determined using the analyze particles function. Below I have code that I wrote to save the actual ROI. I would really like to save the ROI as a csv of X, Y coordinates. This plugin is run with a headless mode so it can not use the window selection tools because there are no open windows.

RoiManager roiManager = new RoiManager();
IJ.run(imp1, "Analyze Particles...", "size=" + minCellSize + "-" + maxCellSize + " exclude include add");
roiManager = RoiManager.getInstance();
Roi[] roiM = roiManager.getRoisAsArray();
for (int z = 0; z < roiM.length; z++) {
        IJ.run("ROI Manager...", "");
        Roi roi1=roiManager.getRoi(z);
        RoiEncoder.save(roi1, "path/here.roi");
}

Thanks,
Kyle
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Getting XY coordinates for a plugin

Jerome Mutterer-3
Hi Kyle,
To save a roi as X and Y coordinates, set imp1 roi with imp1.setRoi(roi1)
and use IJ.saveAs(imp1, "XY Coordinates", "/path/to/textfile.txt") instead.
This is what the File>SaveAs>XY Coordinates command does.

Jerome

2017-02-06 23:33 GMT+01:00 kt7 <[hidden email]>:

> Hi all,
> Stumped again so I am trying to get the coordinates enclosed by a ROI
> determined using the analyze particles function. Below I have code that I
> wrote to save the actual ROI. I would really like to save the ROI as a csv
> of X, Y coordinates. This plugin is run with a headless mode so it can not
> use the window selection tools because there are no open windows.
>
> RoiManager roiManager = new RoiManager();
> IJ.run(imp1, "Analyze Particles...", "size=" + minCellSize + "-" +
> maxCellSize + " exclude include add");
> roiManager = RoiManager.getInstance();
> Roi[] roiM = roiManager.getRoisAsArray();
> for (int z = 0; z < roiM.length; z++) {
>         IJ.run("ROI Manager...", "");
>         Roi roi1=roiManager.getRoi(z);
>         RoiEncoder.save(roi1, "path/here.roi");
> }
>
> Thanks,
> Kyle
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.
> com/Getting-XY-coordinates-for-a-plugin-tp5018040.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>



--
Jerome Mutterer
CNRS - Institut de biologie moléculaire des plantes
12, rue du Général Zimmer
67084 Strasbourg Cedex
www.ibmp.cnrs.fr

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Loading...