Login  Register

Re: capturing summarize info

Posted by Wayne Rasband on May 11, 2006; 2:38am
URL: http://imagej.273.s1.nabble.com/capturing-summarize-info-tp3702782p3702783.html

> I'm learning ImageJ and its macro language and wondered how to
> do the following: capture the threshold and count values from the
> summarize results table, do this for several files, and perform
> calculations on the group of count values.  I'd like to do all this
> within ImageJ if possible; I am able to save the summaries and
> open them in Excel, but that adds a step.  Thank you very much
> for any ideas you have.

The following macro reproduces the particle analyzer's "Summary  
of ..." table. The first two lines are all that is needed to get the  
threshold and count values.

   getThreshold(min, max);
   n = nResults;
   sum = 0;
   for (i=0; i<n; i++)
       sum += getResult("Area", i);
   average = sum/n;
   getPixelSize(unit, pw, ph);
   imageSize = getWidth*getHeight*pw*ph;
   fraction = sum/imageSize;
   print("Threshold:", min+"-"+max);
   print("Count:", n);
   print("TotalArea: "+sum+" "+unit+"^2");
   print("Average Size: "+average+" "+unit+"^2");
   print("Area Fraction: "+d2s(fraction*100,2)+"%");

-wayne