coding with ROIManager

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

coding with ROIManager

Mohamed Tleis
Dear Folks,

I am trying to process a binary image and trying to copy objects into a new
image after adding them to ROI through analyze particles command. I know I
am doing something wrong in my code, can any of you figure it out?

[code]
public class create_Mask {
    public create_Mask(ImagePlus imp)
    {
        ...

        IJ.run(imp, "Analyze Particles...", "size=300-Infinity pixel
circularity=0.00-1.00 show=Nothing add");
        RoiManager manager = RoiManager.getInstance();
        ImageProcessor ip = imp2.getProcessor();

        drawObjects draw = new drawObjects(manager, ip);
        // Objects perfectly drawed into imp2

        ...
        ImagePlus imp3 = IJ.createImage("without_filled", "8-bit White",
im_width, im_height, 1);

        IJ.run(imp, "Convert to Mask", "");
        IJ.run(imp2, "Convert to Mask", "");
        ImageCalculator ic = new ImageCalculator();
        imp3 = ic.run("XOR create", imp, imp2);

....
        IJ.run(imp3, "Analyze Particles...", "size=300-Infinity pixel
circularity=0.00-1.00 show=Nothing add");
        RoiManager manager2 = RoiManager.getInstance();
        ip = imp2.getProcessor();
        drawObjects draw2 = new drawObjects(manager2, ip);

        // objects in ROI are not drawed here
    }
}
[/code]

Thanks in advance,
Best Regards,
Mohamed Tleis