How to make a stack from images the imglib2 way?

I am having problem thinking the imglib2 way. So a newbie question: which is the best way to combine several 2D images (actually 3) into a multidimensional image using only imglib2? The goal is to consider the resulting image composed of 3D vectors. I would use a stack in ImageJ1, but I realized imglib2 supports mutidimensional images directly.


You can use the static helper class net.imglib.view.Views.

Here’s an example Groovy script that stacks three input images into a 3D stack:

// @Dataset img1
// @Dataset img2
// @Dataset img3
// @UIService ui

import net.imglib2.view.Views

list = [img1, img2, img3]

output = Views.stack(list)