|
Hi There,
I am writing on an ImageJ Plugin, which should create a ImageStack of Rois from an initial image.
My Problem:
The Stack contained just white images without the Rois.
The Code of my Plugin:
----------------------------------------------------------
import ij.IJ;
import ij.ImagePlus;
import ij.ImageStack;
import ij.gui.Roi;
import ij.plugin.filter.PlugInFilter;
import ij.process.ImageProcessor;
public class Copy_Paste implements PlugInFilter {
ImagePlus imp;
ImageStack stack = new ImageStack(150, 150);
public int setup(String arg, ImagePlus imp){
if(imp == null) {
return DONE;
}
this.imp = imp;
return DOES_ALL;
}
public void run(ImageProcessor ip){
ImagePlus impTwo;
Roi roi;
for(int i = 0; i < 100; i++){
impTwo = IJ.createImage("", "RGB White", 150, 150, 1);
roi = new Roi(i, i, 100, 100);
imp.setRoi(roi);
imp.copy(false);
impTwo.paste();
stack.addSlice(impTwo.getProcessor());
impTwo = null;
}
new ImagePlus("Objects", stack).show();
}
}
----------------------------------------------------------
BTW: If you insert impTwo.show() after the line impTwo.paste() then it works, but i don't wanna see every single picture. (It's part of a bigger program and there can be up to 300 rois)
I hope someone knows a solution.
Cheers,
Stephan
|