Completely clearing drawn ROIs from an image with RoiManager...

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

Completely clearing drawn ROIs from an image with RoiManager...

keesh
Dear Image/J Lurkers,

I'm programmatically creating three (3) OvalRoi's on a single image using the RoiManager.
As a user option, I wish to later -completely- clear all 3 ROIs from the same image.

I can successfully remove all ROIs from the RoiManager and
seemingly kill the current Roi from the ImagePlus,
but 2 of the 3 drawn ROIs still appear in the foreground color on the image.

I've tried resetting the image from its snapshot; calling updateAndRepaintWindow and
the other update/draw functions; and also tried various canvas repainting including
Graphics' clearRect, fillRect to no avail.

Any tips or incantations would be greatly appreciated.

Code fragment)
 // Traverse Roi Mgr's list of Rois and select each one in turn.
 // Error checking omitted
 protected RoiManager rm;
 ...
 Roi roi = new OvalRoi(circLeftRound, circTopRound, circWidthRound, circHeightRound);
 imp.setRoi(roi);
 rm.runCommand("Add & Draw"))  // once drawn cannot be removed?
 ...
 ...
 List list = rm.getList();
 Hashtable rois = rm.getROIs();
        for (int i = list.getItemCount() - 1; i >= 0; i--) {
            String roiID = (String) list.getItem(i);
            Roi roi = (Roi) rois.get(roiID);
            rm.select(i);
            imp.killRoi();
            rm.runCommand("Delete");
        } // for i
        // reset image from its cached snapshot (when the plugin first ran)
        handleDOUndo(); // really a fancy ipDO.reset();
        imp.updateAndRepaintWindow();
        cc.repaint();  // repaint the custom canvas


******************************************
keesh
Software Development Engineer
(Alchemist of the Millennium)

Contact:
[hidden email]
******************************************

Life Plan:
To improve the quality of life for all mankind through better pattern
recognition techniques.