How to combine sets of images in a stack in imageJ?

125 views Asked by At

For example, let's say I have a stack of 20 images, and I want to combine every 4 images in the stack together (add the values up) and get a new stack of just 5 images.

2

There are 2 answers

0
Herbie On

What you need is the "Grouped z-Project..."-operation. Below is an ImageJ-macro snippet that shows the relevant code:

//
run("MRI Stack");
run("Grouped Z Project...", "projection=[Average Intensity] group=3");
//

The "MRI"-stack shows 27 slices. If grouped to 3, the resulting stack consists of 9 slices. Please note that averaging is the way to go for integer images because summation can easily lead to an overflow. If you prefer summing instead of averaging, you should first convert your stack zu 32bit float.

0
anerlich On

Summing up the slices ("Projection Method: Sum Slices") will automatically convert the image to 32-bit. No need to convert to 32-bit first (as I also just figured out recently).

//
run("MRI Stack");
run("Grouped Z Project...", "projection=[Sum Slices] group=3");
run("Show Info...");
//