Re: Getting the number of pixels which values are below a certain threshold

Posted by Michael Schmid on
URL: http://imagej.273.s1.nabble.com/Getting-the-number-of-pixels-which-values-are-below-a-certain-threshold-tp3688975p3688976.html

Hi Stephan,

this should be easy:
   getStatistics(area, mean, min, max, std, histogram);
In a 'for' loop, sum up all values in the histogram array from index  
0 to
   floor(lengthOf(histogram)*(threshold-min)/(max-min))
where threshold is -500 in your case.
Write the result to a file:
  f = File.open(path);
  print(f, result);
in your shell script or batch file, you can read the value from the  
file.


Michael
________________________________________________________________

On 1 Mar 2010, at 18:18, Stephan Bender wrote:

> Hello,
>
> I'm quite new to ImageJ, I hope someone can help me with this task:
>
> I need get the number of pixels which values are below a certain  
> threshold. The image format is DICOM (16 bit), and I need the  
> result on a Unix command line, so I guess I'll have to use a macro  
> function.
> A common image has appr. 60% of the pixel values from -2048 to  
> -500, I need to know the exact number of pixels below -500.
>
> Thank you very much for your help!
>
> Best regards,
>
> Stephan