Draw overlay on a dataset (or iterate through pixels of the contour of an overlay)

Hello everyone !

Is there a function with ImageJ2 or Overlay which draws the contour of PolygonOverlay on a dataset (or a RandomAccess that goes through all the pixel of the contour of the overlay ?)

Cheers,

Cyril

1 Like

Hi @cmongis,

I think you are looking for functionality in ImageJ2’s OverlayService. OverlayService.drawOverlay() should do the trick for you.

Best,
Stefan

Hello @stelfrich,

thanks for the tips but I already used this service but the problem is that it doesn’t take account the “lineWidth” of the overlay. I would need an iterator that allows me to iterate through the neighbours of pixel position for instance or an iterator that takes the this into account which would allow me to draw on a dataset directly.

(On the picture here, drawing is done using the JavaFX nodes. I want to reach the same result but at a dataset level).

Also, I’m also confused about something. When should we use Ops and when not ?

I’ve probably said this before, but ImageJ2’s Overlay classes are highly incomplete compared to ImageJ 1.x. Furthermore, the drawing of ImageJ2’s Swing UI cheated by using JHotDraw. We definitely want to move away from this in favor of algorithms in ImageJ Ops that render ROIs in a UI-agnostic way. This is a highly unexplored & unimplemented area of ImageJ2, which many people want and need, but no one has time to work on. :frowning:

Relatedly: @cmongis Do you have time and interest to attend the upcoming ImageJ/KNIME hackathon in Konstanz? It seems you are pretty close by! July 5 - July 14. It would be super awesome if you could come. We would really be able to hammer out some stuff and get onto the same page, and maybe make some plans on how to tackle these things as a community! :+1:

The ImageJ Ops project is for coding UI-independent image processing algorithms which are deterministic in nature. This is starting to include 3D stuff like marching cubes, backed by ImgLib2 data structures. In the future, I hope it will back ROI rendering too. We have to be careful about performance though, esp. regarding highly user-interactive operations.

4 Likes