Login  Register

Re: Trouble with writing a macro: setThreshold

Posted by Wayne Rasband on Jan 27, 2009; 4:38pm
URL: http://imagej.273.s1.nabble.com/Trouble-with-writing-a-macro-setThreshold-tp3693903p3693904.html

> Hi,
>
> I'm trying to write a macro that will determine the gray value 3.5
> standard
> deviations higher than the mean, from a selected region of the image.
> Apparently, this was possible on an older version of ImageJ running on
> Mac
> OS 9, but I'm using OS X and the macro language has changed. I have no
> previous experience writing macros, so please bear with me.
>
> The problem I'm having is with setting the lower limit on the
> threshold. I'd
> like it to be a variable equal to the parameters given above,
> "3.5*StdDev +
> Mean" (actually, rounded to the next integer), but I don't really know
> how
> to go about defining such a variable.

Use the getRawStatistics() macro function to get the standard deviation
and setThreshold() to set the Threshold. Here is an example:

   getRawStatistics(nPixels, mean, min, max, stdDev);
   t1 = 3.5*stdDev+mean;
   t2 = max;
   setThreshold(t1, t2);

-wayne