Question about : Measurements into resultsTable

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

Question about : Measurements into resultsTable

Mohamed Tleis
Dear Members;

I wrote the following simple program; In which I expect the results
table to get the meausred data of an ROI; but checking column 0 returns
false; Although I can see the output on my terminal; I wonder what I am
missing to output measurements into results table.

import ij.IJ;
import ij.ImagePlus;
import ij.gui.OvalRoi;
import ij.measure.ResultsTable;

public class measureHoughtest {
     public static void main(String args[])
     {
         ImagePlus imp = IJ.createImage("Testing Image", "8-bit White",
512, 512, 1);
         OvalRoi or = new OvalRoi(10, 10, 12, 12);
         imp.setRoi(or);
         IJ.run(imp, "Measure", "");
         ResultsTable rt = ResultsTable.getResultsTable();
         System.out.println("rt.exists : "+ rt.columnExists(0) );
     }
}


Best Regards,
Mohamed Tleis

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Question about : Measurements into resultsTable

Rasband, Wayne (NIH/NIMH) [E]
On Jul 21, 2012, at 7:35 AM, Mohamed Tleis wrote:

> Dear Members;
>
> I wrote the following simple program; In which I expect the results
> table to get the meausred data of an ROI; but checking column 0 returns
> false; Although I can see the output on my terminal; I wonder what I am
> missing to output measurements into results table.

Use the ResultsTable.getValue(heading, row) method to retrieve values from the results table.

   imp = IJ.createImage("Testing Image", "8-bit White", 512, 512, 1);
   or = new OvalRoi(10, 10, 12, 12);
   imp.setRoi(or);
   IJ.run(imp, "Measure", "");
   rt = ResultsTable.getResultsTable();
   IJ.log("area: "+rt.getValue("Area", 0));
   IJ.log("mean: "+rt.getValue("Mean", 0));

Or simplify the code and avoid displaying the results table by using ImagePlus.getResults().

   imp = IJ.createImage("Testing Image", "8-bit White", 512, 512, 1);
   or = new OvalRoi(10, 10, 12, 12);
   imp.setRoi(or);
   stats = imp.getStatistics();
   IJ.log("area: "+stats.area);  IJ.log("mean: "+stats.mean);

-wayne






>
> import ij.IJ;
> import ij.ImagePlus;
> import ij.gui.OvalRoi;
> import ij.measure.ResultsTable;
>
> public class measureHoughtest {
>     public static void main(String args[])
>     {
>         ImagePlus imp = IJ.createImage("Testing Image", "8-bit White",
> 512, 512, 1);
>         OvalRoi or = new OvalRoi(10, 10, 12, 12);
>         imp.setRoi(or);
>         IJ.run(imp, "Measure", "");
>         ResultsTable rt = ResultsTable.getResultsTable();
>         System.out.println("rt.exists : "+ rt.columnExists(0) );
>     }
> }
>
>
> Best Regards,
> Mohamed Tleis
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

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