Get specific slice in imageStack and show

Hi guys,

I know it might be a entry-level question but I just can’t figure it out.

If I have an imageStack instance and I want to get the specified slice in an iteration(for loop with index indicating the slice no in the stack). After getting the slice I want to show it one after another. How can I do that ???

The pseudo code:

for (int i = 1; i < stack.size(); i++)
    ImagePlus currentSlice = stack.get(i);;


Welcome to the forum, @blueclowd!

The main image class of ImageJ 1.x is called ImagePlus. If the image has more than one plane, it has an attached ImageStack, which you can think of as a lower level piece of the ImagePlus which houses its actual planes, the ImageProcessor objects.

To display a particular slice, use the setSlice method of ImagePlus. If you have a multidimensional image (possible dimensions include Z, channel and time), you can also use setPosition.

1 Like

Thanks ctrueden, you rock.