Login  Register

Re: Getting the ResultTable and ROI after an analyse particles

Posted by Rasband, Wayne (NIH/NIMH) [E] on Jun 20, 2010; 8:01pm
URL: http://imagej.273.s1.nabble.com/LIF-reader-tp3687880p3687884.html

On Jun 20, 2010, at 11:48 AM, Paul Dufouleur wrote:

> Hi everyone,
>
> I have problem to get and use the results and the ROI that the function "Analyse Particles" gave me with the following line:
>
> IJ.run(imp, "Analyze Particles...", "size=0.00-Infinity circularity=0.00-1.00 show=[Masks] display clear add");
>
> Could someone help me to put them in an object ResultTable and ROI?

You can get the ResultsTable using

   ResultsTable rt = ResultsTable.getResultsTable();

You can get a list of the ROIs using

   Overlay rois = imp.getOverlay();

if you use the show="Overlay Outlines" option that was added to the particle analyzer in ImageJ 1.44b. This works because because an Overlay is basically just a list of ROIs.

Here is an example:

   imp = IJ.openImage("http://rsb.info.nih.gov/ij/images/blobs.gif");
   IJ.setAutoThreshold(imp, "MaxEntropy");
   IJ.run("Set Measurements...", "area mean");
   IJ.run(imp, "Analyze Particles...", "show=[Overlay Outlines] clear");
   rois = imp.getOverlay();
   rt = ResultsTable.getResultsTable();
   for (i=0; i<rois.size(); i++)
       IJ.log(i+"  "+rois.get(i)+", area="+rt.getValue("Area", i));

-wayne