Login  Register

Re: How can I access to the whole stack?

Posted by Fabrice Senger on Jul 07, 2009; 12:43pm
URL: http://imagej.273.s1.nabble.com/How-can-I-access-to-the-whole-stack-tp3691874p3691878.html

Juanjo Vega a écrit :

> Hello,
>
> I'm trying to process an entire stack, but I'm having some problems.
>
> I wrote the code below in order to understand how to access to each
> one of the stack slices. The idea is to copy the whole stack into a
> matrix where each row is a slice and columns store the array of pixels
> for that slice.
>
> The code is very simple, but there's a problem is with
> "getProcessor()". It doesn't work and I don't know what I'm doing
> wrong, or if there is another way to get the slice without this method.
>
>        ImagePlus imgSource;
>
>        ...
>
>        short inPixels[][] = new short[imgSource.getStack().getSize()][];
>        for (int stack = 0; stack < inPixels.length; stack++) {
>            IJ.write(" *** Stack : " + stack + " / " +
> imgSource.getStack().getSize());
>            inPixels[stack] = (short[])
> imgSource.getStack().getProcessor(stack).convertToShort(true).getPixels();
>
>        }
>
> I also tried to look at:
> http://rsb.info.nih.gov/ij/source/ij/plugin/filter/Duplicater.java
>
> Sincerelly,
>
> Juanjo Vega.
>
Hi,

this might sound simplistic but, you can save your stack to a folder as
an image sequence, next you can process each image in that folder. Thus
you will access the information for each slice in the original stack...

Fabrice.

--
Senger Fabrice