Polygon ROI java coding problem

Java plugin - I’m prompting the user to create POINT and POLYGON ROIs.

For POINT ROI, this seems to work just fine:

 WaitForUserDialog wfudOCT = new WaitForUserDialog("select three (3) landmarks in OCT; then click OK");
 Roi octLMROI = octIPlus.getRoi();
 Polygon octLMPolygon = octLMROI.getPolygon();

But, for POLYGON ROI, this very similar code fails:

 WaitForUserDialog wfudOCT = new WaitForUserDialog("select Polygon in OCT; then click OK");
 Roi octPolyROI = octIPlus.getRoi();
 Polygon octPolygon = octPolyROI.getPolygon();

In the second case, octPolyROI is null. The user has drawn a polygon (and completed it) and then clicks on “OK” in the dialog box. The polygon is displayed on the image (with the verticies minimized)

What am I doing wrong?

I do notice that there’s a difference in how the “multipoint” and “Polygon selections” are presented in the
ImageJ toolbar.

If it matters, this is running under FIJI, latest version.


Hello Kenneth,

you can get the Polygon from the PolygonROI with:

ImagePlus plu=WindowManager.getCurrentImage();
ROI roi = plu.getRoi();
Polygon po = roi.getPolygon();
int[] roix = po.xpoints;
int[] roiy = po.ypoints;

Great to see you on the forum, @KennethRSloan!

I’m just cross-linking to the mailing list here, as your post was answered there by @ctrueden already:


In the future, if cross-posting to the list and here on the forum, please just include a link on both ends so that others can follow the discussion :slight_smile:

1 Like