Java plugin - I’m prompting the user to create POINT and POLYGON ROIs.
For POINT ROI, this seems to work just fine: IJ.setTool("multipoint"); WaitForUserDialog wfudOCT = new WaitForUserDialog("select three (3) landmarks in OCT; then click OK"); wfudOCT.show(); Roi octLMROI = octIPlus.getRoi(); Polygon octLMPolygon = octLMROI.getPolygon(); But, for POLYGON ROI, this very similar code fails: IJ.setTool("polygon"); WaitForUserDialog wfudOCT = new WaitForUserDialog("select Polygon in OCT; then click OK"); wfudOCT.show(); 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. -- Kenneth Sloan [hidden email] <mailto:[hidden email]> Vision is the art of seeing what is invisible to others. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Kenneth,
I am unable to reproduce the faulty behavior on my system. With the following Groovy script: import ij.IJ import ij.gui.WaitForUserDialog imp = IJ.openImage("http://imagej.net/images/blobs.gif") imp.show() IJ.setTool("polygon") new WaitForUserDialog("select Polygon in OCT; then click OK").show() roi = imp.getRoi() println("roi = " + roi) println("polygon = " + roi.getPolygon()) I see output like the following: roi = Roi[Polygon, x=68, y=34, width=142, height=152] polygon = java.awt.Polygon@452535bd Is it possible the user is drawing in a different image than the one referenced by your octIPlus? Regards, Curtis -- Curtis Rueden LOCI software architect - https://loci.wisc.edu/software ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden Did you know ImageJ has a forum? http://forum.imagej.net/ On Wed, Oct 25, 2017 at 5:35 PM, Kenneth Sloan <[hidden email]> wrote: > Java plugin - I’m prompting the user to create POINT and POLYGON ROIs. > > For POINT ROI, this seems to work just fine: > > IJ.setTool("multipoint"); > WaitForUserDialog wfudOCT = new WaitForUserDialog("select three (3) > landmarks in OCT; then click OK"); > wfudOCT.show(); > Roi octLMROI = octIPlus.getRoi(); > Polygon octLMPolygon = octLMROI.getPolygon(); > > > But, for POLYGON ROI, this very similar code fails: > IJ.setTool("polygon"); > WaitForUserDialog wfudOCT = new WaitForUserDialog("select Polygon in > OCT; then click OK"); > wfudOCT.show(); > 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. > > -- > Kenneth Sloan > [hidden email] <mailto:[hidden email]> > Vision is the art of seeing what is invisible to others. > > > > > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Thanks for checking. I’ll dig deeper, tomorrow.
I posted because I hit a brick wall, and am still uncertain enough about working from the API docs that I thought there was a real possibility I had made an elementary mistake. But…if the code looks right to you - then something else is going on. Clearly, this is an excerpt from a much larger program. Again - thank you very much for verifying that this *should* work. -- Kenneth Sloan [hidden email] <mailto:[hidden email]> Vision is the art of seeing what is invisible to others. > On Oct 25, 2017, at 23:29 , Curtis Rueden <[hidden email]> wrote: > > Hi Kenneth, > > I am unable to reproduce the faulty behavior on my system. > > With the following Groovy script: > > import ij.IJ > import ij.gui.WaitForUserDialog > imp = IJ.openImage("http://imagej.net/images/blobs.gif <http://imagej.net/images/blobs.gif>") > imp.show() > IJ.setTool("polygon") > new WaitForUserDialog("select Polygon in OCT; then click OK").show() > roi = imp.getRoi() > println("roi = " + roi) > println("polygon = " + roi.getPolygon()) > > I see output like the following: > > roi = Roi[Polygon, x=68, y=34, width=142, height=152] > polygon = java.awt.Polygon@452535bd > > Is it possible the user is drawing in a different image than the one > referenced by your octIPlus? > > Regards, > Curtis > > -- > Curtis Rueden > LOCI software architect - https://loci.wisc.edu/software <https://loci.wisc.edu/software> > ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden <https://imagej.net/User:Rueden> > Did you know ImageJ has a forum? http://forum.imagej.net/ <http://forum.imagej.net/> > > > On Wed, Oct 25, 2017 at 5:35 PM, Kenneth Sloan <[hidden email] <mailto:[hidden email]>> > wrote: > >> Java plugin - I’m prompting the user to create POINT and POLYGON ROIs. >> >> For POINT ROI, this seems to work just fine: >> >> IJ.setTool("multipoint"); >> WaitForUserDialog wfudOCT = new WaitForUserDialog("select three (3) >> landmarks in OCT; then click OK"); >> wfudOCT.show(); >> Roi octLMROI = octIPlus.getRoi(); >> Polygon octLMPolygon = octLMROI.getPolygon(); >> >> >> But, for POLYGON ROI, this very similar code fails: >> IJ.setTool("polygon"); >> WaitForUserDialog wfudOCT = new WaitForUserDialog("select Polygon in >> OCT; then click OK"); >> wfudOCT.show(); >> 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. >> >> -- >> Kenneth Sloan >> [hidden email] <mailto:[hidden email]> <mailto:[hidden email] <mailto:[hidden email]>> >> Vision is the art of seeing what is invisible to others. >> >> >> >> >> >> -- >> ImageJ mailing list: http://imagej.nih.gov/ij/list.html <http://imagej.nih.gov/ij/list.html> >> > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html <http://imagej.nih.gov/ij/list.html> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |