How to get max value of stack using macro?

Tags: #<Tag:0x00007fd541cef5e0> #<Tag:0x00007fd541cef478>


Hi, I’m a complete novice with using macros for ImageJ so bear with me.
I’m trying to divide a stack with z-slices with the max value of the stack using macro. I can get the value by going to Histogram with Stack histogram ticked. But the macro I wrote only gave the max value for the first slice of the stack.

The macro I have so far:

for (j=1;j<slices+1;j++){
getStatistics(area, max);
maxred = max;

run(“Divide…”, “value=maxred”);



In your case I will use the “Z project” method to get maximum of each pixel of each slice in a single image then you get the max of this image.

If it helps you…


Hi @dentedaura,

you can also use

Stack.getStatistics(voxelCount, mean, min, max, stdDev);

to get the maximum value of the stack.


Thanks! This works perfectly.