|
On Feb 14, 2011, at 8:08 AM, Tony Shepherd wrote:
> I have a plugin that produces a stack to display 4D data, but the user must finally use the menu options "Image -> Stack -> Stack to Hyperstack" to turn the resultsing stack into a HypetStack. To do this automatically for the user, what commands can I use in the plugin code (something like "imp.createHyperstackFromStack(args)" or stack.sortIntoHyperstack(args)..) since there is no constructor for a HypetStack object?
Use the ImagePlus methods setDimensions() and setOpenAsHyperStack(true) to display a stack contained in an ImagePlus as a hyperstack. Convert the ImagePlus to a CompositeImage if the stack has more than one channel. Here is an example:
width = 256;
height = 256;
channels = 3;
slices = 10;
frames = 20;
images = channels*slices*frames;
imp = IJ.createImage("Test", "8-bit black", width, height, images);
imp.setDimensions(channels, slices, frames);
if (channels>1)
imp = new CompositeImage(imp, CompositeImage.COMPOSITE);
imp.setOpenAsHyperStack(true);
imp.show();
-wayne
|