Login  Register

Re: Working with stacks

Posted by Julian Cooper on Jun 09, 2009; 2:35pm
URL: http://imagej.273.s1.nabble.com/Working-with-stacks-tp3692217p3692218.html

Hi Juanjo,

If I understand you correctly you can achieve what you describe in your
first paragraph by drawing your rectangle ROI, and then go to Image >
Duplicate (or press Ctrl, Shift and D). Make sure the duplicate stack
checkbox is selected and leave the range as it is if you want the whole
stack of rectangles. A new stack will open with the stack of ROIs.

Kind regards,

Julian

> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]] On
> Behalf Of Juanjo Vega
> Sent: 09 June 2009 14:33
> To: [hidden email]
> Subject: Working with stacks
>
>
> Hello everyone, I want to copy a ROI from a stack of images.
>
> The idea is to select a rectangle from the stack of images and then,
> when a button is pressed, a new image containing the stack of ROIs is
> created.
>
> I'm doing this, but it doesn't works (only the first image is
> created).
> The problem is that I don't know where to find some help about how to
> work with stacks to get a slice, replace, add a new one, or whatever.
>
> Right now I'm doing this, but I tried many other stuff
> without success:
>  
>        Roi roi = IJ.getImage().getRoi();
>
>         Point a = new Point(roi.getBounds().x, roi.getBounds().y);
>         Point b = new Point(roi.getBounds().x +
> roi.getBounds().width,
> roi.getBounds().y + roi.getBounds().height);
>
>        short copy[][] = new short[IJ.getImage().getStackSize()][];
>
>        for (int i = 0; i < IJ.getImage().getStackSize(); i++) {
>            copy[i] = AUXcopyArea(IJ.getImage().getProcessor(), a, b);
>        }
>
>        ImageProcessor ipp = new ShortProcessor(roi.getBounds().width,
> roi.getBounds().height, copy[0], null);
>        ImagePlus processedImg = new ImagePlus("Processed", ipp);
>
>        for (int i = 0; i < IJ.getImage().getStackSize(); i++) {
>            processedImg.getStack().setPixels(copy[i], i);
>        }
>
>        processedImg.getProcessor().resetMinAndMax();
>        processedImg.show();
>
>
>
> Sincerelly,
>
> Juanjo.
>
> --
> Juanjo Vega ([hidden email])
>
> Unidad de Biocomputación. Laboratorio B-13.
> Centro Nacional de Biotecnología. CNB-CSIC.
> C\ Darwin, 3. Campus de Cantoblanco.
> Universidad Autónoma de Madrid.
> 28049, Madrid, Spain.
>
> http://www.cnb.csic.es
> http://www.biocomp.cnb.uam.es
>
> +34 91 585 4510
>
>
> "Las mejores almas son capaces de los mayores vicios como de
> las mayores virtudes, y aquellos que caminan despacio por el
> camino recto pueden llegar más lejos que los que corren pero
> se apartan de él." - Discurso del Método, René Descartes.
>