Normalizing intensity for each channel in a stack

Hi everyone,

Can someone advise on how I can normalize the intensity of each channel to the brightest pixel of the corresponding channel (within a stack)? I wrote the following function and it seems that when I perform the division on the brightest pixel (of the corresponding channel), the division is applied to all 3 channels. How do I ensure that the normalization is specific to the corresponding channel?

function Norm2BrightestInt(){
	Stack.getDimensions(width, height, channels, slices, frames);
		for(i=0; i<channels; i++){
			//run("Select All");
			run("Divide...", "value=max");
	else {
			run("Select All");
			run("Divide...", "value=&max");

Thanks in advance.


Have you thought about perhaps splitting the channels first? Then selecting each window as you go - applying your normalization - and then at the end, you can merge the channels once again. Not sure this is the best fix … but might be a decent workaround for now.


Hi etarena,

I’m sorry about the latent reply. That’s actually what I’ve been doing. Just wondering if there’s a neater to get around this problem as it makes the code bulky.