Adjusting brightness to one level in a stack of images


I have the following problem:
There is a stack of images (grayscale,16bit) where the slices have different levels of brightness.
To compare the slices among each other, I want to adjust the brightness to the same level in all slices.

Does someone could help me with an apporach?

Thank you very much,

Hi tarantina,

a simple approach is to normalize the mean of each slice of the stack to 1. The following macro does that with a duplicate of the original stack.

title = getTitle();
run("Duplicate...", "title=" + title + "-norm duplicate");
for (i = 1; i <= nSlices; i++) {
    getStatistics(area, mean, min, max, std, histogram);
    run("Divide...", "value=" + mean + " slice");
    // run("Set Label...", "label=" + mean);
run("Enhance Contrast", "saturated=0.35");

This approach does not exclude outliers and may result in slices with a slight difference in brightness. If your stack does not contain slice labels, you can uncomment the line with run("SetLabel..." to write the mean value to each slices label. A better approach is to copy each slice separately, use Enhance Contrast on it, run Overlay>Flatten and finally create a new stack from all newly created 8-bit images. Using the Macro language, this will be awkward, but with JavaScript, Jython, … one can accomplish this task with a few lines of code.

You will always lose the original counts of the images. That is because the ImagePlus is designed to use the same display limits for all slices of a stack. Maybe there is a plugin that extends ImagePlus and uses a EventListener to adjust brightness and contrast when changing the slice.