Imagej polygon ROI: How to undo a point in the middle of drawing process


When someone draws a plygon ROI in a large image, and made a mistake (e.g.,draws a point to the wrong position), is there a way to undo the last point and contniue with the point before the last point?
If start again from beginning, it will waste a lot of efforts.


Hi @mendel
Hold the alt (mac) key and move your mouse back toward the previous point. This will do exactly what you want; the point disappears. You can repeat this and all previous points will vanish one by one.

Alternatively, set an extra point and keep drawing the polygon. After you finish, alt-click the offending one and/or move the auxiliary point in the right location.

From a freehand tool ROI you can run this tiny macro to create handles in order to edit the shape:

run("Interpolate", "interval=15 adjust");


Thanks, this solved my problem.
By the way, is there a imagej menue that can set the value of Interpolate-interval?



will bring up a menu for the interval when an image is open and a selection is active.
All functions are documented, see e.g. getSelectionCoordinates(xpoints, ypoints)

Is there a way to change the interval forever? I found that it only works for current selection.

I solved by code:

 aRoi =ips.getRoi;
    aFloatPolygon = aRoi.getInterpolatedPolygon(6,1) %getFloatPolygon();
    aVirtualRoi = ij.gui.PolygonRoi(aFloatPolygon.xpoints,aFloatPolygon.ypoints,aFloatPolygon.npoints,ij.gui.Roi.POLYGON);

apart from removing a point from a finished polygonRoi, is there a way to add an additional point to the finished polygonRoi? Thanks

I haven’t found a way yet. Trick could be to interpolate with a distance less than your points are apart, then you get a series of regularly spaced handles that do not do anything for the edges you are not interested in, but gives you new handles to move about.

Via macro it would be possible to add one point between each point pair you have on the polygon, then ignore the ones you are not interested in.

I’ve made a macro in the past that after activation follows the cursor along the nearest point of the ROI and does something (add a point in your case) when you click the mouse. Briefly, you add the ROI to the ROI manager in order to keep it in its original state, interpolate the ROI with a step of 1 in the image, get the coordinates of (then) all points on the ROI, do some math to deduce the point nearest the cursor but on the ROI and wait for a click. Then take the currently active point on the roi and insert its coordinates in between the pair of the original polygon. Involved? Yes. Impossible? No.
Probably there is an easier method, but I stick to ImageJ1 macro language.

1 Like

is there a way to add an additional point to the finished polygonRoi?

SHIFT-click on a point. It will spit into two points, which interpolate between this point ands its neighbors. Of course, like any polygon point, these can be moved by dragging with the mouse.