Login  Register

Re: Collate PlotWindows into a stack

Posted by Albert Cardona on May 16, 2008; 1:43am
URL: http://imagej.273.s1.nabble.com/Collate-PlotWindows-into-a-stack-tp3696195p3696196.html

Mike,


> My plugin generates numerous plotWindows that eventually take over the
> screen.  Is there an easy way to have each new plotWindow placed into
> a stack?


PlotWindow is an extended ImageWindow, thus you can call
getImagePlus().getProcessor() on it. So to make a stack:


PlotWindow[] pw = ....

ImageProcessor ip = pw[0].getImagePlus().getProcessor();
int w = ip.getWidth();
int h = ip.getHeight();

ImageStack stack = new ImageStack(w, h);
stack.addSlice("plotwindow 1", ip); // the first one

// start at the second one, index 1
for (int i=1; i<pw.length; i++) {
    stack.addSlice("plotwindow" + (i+1),
pw[i].getImagePlus().getProcessor());
}


new ImagePlus("All PlotWindows", stack).show();


--
Albert Cardona
http://www.mcdb.ucla.edu/Research/Hartenstein/acardona