> hello imagej users,
>
> i'm trying to obtain statistics (e.g. mean pixel value or standard
> deviation
> of all pixel values) of entire stacks using macros. would any of you
> be able
> to show me how to do this?
>
> in particular, my task is to use a macro to open a stack, determine
> its mean
> pixel value and the standard deviation of the pixel values (of all
> pixels in
> the stack, not just a single slice), and then use that information as
> parameters for further processings, e.g. thresholding.
>
> if i want to do this "by hand," i can simply use ctl-h to use the
> histogram
> function. however, i'm not sure how to do something like this in a
> macro - i
> can of course do a "Run("histogram", "stack")" but then i am not quite
> able
> to extract the mean/std values that i need.
>
> at this point my solution is to actually open the stack in matlab and
> pass
> the necessary parameters to the iamgej macro as an argument. this
> offers
> additional flexibility since i can calculate whatever i want in matlab
> - it
> is just extremely slow to open stacks in matlab.
The ImageJ 1.42m daily build adds a Stack.getStatistics() macro
function for getting statistics of an entire stack. Here is an example:
Stack.getStatistics(count, mean, min, max, std);
print("count="+count+", mean="+mean+", min="+min+", max="+max+",
std="+std);
-wayne