Re: getPixels on ImageStack
Posted by
Albert Cardona on
May 26, 2008; 2:01pm
URL: http://imagej.273.s1.nabble.com/getPixels-on-ImageStack-tp3696139p3696140.html
frenshilo wrote:
> Hi everyone.
>
> I would like some help in converting an ImageStack to a byte[], as getPixels
> method does to an ImageProcessor.
>
ImageStack has a method named "getPixels(int n)" which, if the stack is
made of ByteProcessor, will return byte[] for each slice from 1 to n.
http://rsb.info.nih.gov/ij/developer/api/ij/ImageStack.htmlSo all you need to write is:
ImagePlus imp = IJ.getImage();
ImageStack stack = imp.getStack();
if (null == stack) return;
// from 1 to size, reversed:
for (int i=stack.getSize(); i>0; i--) {
myPlugIn((byte[])stack.getPixels(i));
}
> I´m processing 3D images and I want to reuse some older plug-in I developed
> to deal with 2D images.
>
Albert
--
Albert Cardona
http://www.mcdb.ucla.edu/Research/Hartenstein/acardona