Using preallocated ImageStacks
Posted by Adam Waite on May 23, 2010; 7:14am
URL: http://imagej.273.s1.nabble.com/Using-preallocated-ImageStacks-tp3688198.html
Hello,
I am trying to write a method that takes a list of images and converts them to a stack. Since I know the size of the list, I would like to use the ImageStack constructor that allows for preallocation. I might be missing something very simple, but I cannot figure out the correct series of calls to assign each ImageProcessor from my list of images to the preallocated ImageStack. The closest I can get is
// list = my list of ImagePlus objects
ImageStack stack = new ImageStack(xdim,ydim,list.size())
for (int i=0; i<list.size(); i++) {
ImageProcessor ip = stack.getProcessor(i+1);
ip = list.get(i).getProcessor().duplicate();
}
This compiles, but if I try to run it, I get the following error:
Exception in thread "Run$_main" java.lang.IllegalArgumentException: Pixel array is null
Any help? It should be more efficient to preallocate the ImageStack if possible, but perhaps this is not true. If not, then using addSlice() is easy enough.
Thanks,
Adam
=====
Science is more of an art than a science.