Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
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. |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
Adam,
I think this is because when you call getProcessor() the pixel array in that slice of the stack has not been initialised. You could try using this instead: ImageStack stack = new ImageStack(xdim,ydim,list.size()) for (int i=0; i<list.size(); i++) { ImageProcessor ip = list.get(i).getProcessor(); stack.setPixels(ip.getPixels, i+1); } I always tie myself in knots doing this simple stuff. Michael On 23/05/10 08:14, Adam wrote: > 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. ... [show rest of quote]
|
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
Thank you, Michael, that did the trick!
Yes, this simple task has had me banging my head against the wall for a couple days, now. Adam ===== Science is more of an art than a science. ----- Original Message ---- > From: Michael Doube <[hidden email]> > To: [hidden email] > Sent: Sun, May 23, 2010 12:40:45 PM > Subject: Re: Using preallocated ImageStacks > > Adam, I think this is because when you call getProcessor() the pixel > array in that slice of the stack has not been initialised. You could try > using this instead: ImageStack stack = new > ImageStack(xdim,ydim,list.size()) for (int i=0; i<list.size(); > i++) { ImageProcessor ip = > list.get(i).getProcessor(); stack.setPixels(ip.getPixels, > i+1); } I always tie myself in knots doing this simple > stuff. Michael On 23/05/10 08:14, Adam wrote: > > 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. ... [show rest of quote]
|
Free forum by Nabble | Disable Popup Ads | Edit this page |