To be honest, JTS was not really on my radar before. Looking at it now, it appears that it is a 2D-only library? Whereas the ImgLib2 ROI model is N-dimensional. I would hope that a JTS-backed implementation of ImgLib2 ROIs would be possible, although I know of no use case for it currently.
JTS support z coordinate, but it is just a mark, all the geometry operation are based 2D.
ImageJ support nd roi? a 3d roi means a stl model, I thing it is 3d edite soft ware’s task, such as blender. And I can not perceive vector roi more than 3d.
In ImgLib2, a
RealMask (i.e. ROI) is a function that tells you, for a given N-dimensional coordinate, whether that coordinate is part of the ROI (
true) or not (
RealMask is a Java
Predicate. They have some additional features, such as having a border type (e.g. closed rectangle vs. open rectangle). Most of the ROI types extend just fine into N dimensions; the exception is polygon, so ImgLib2 currently has only a
Polygon2D implementation. But for polylines, boxes and ellipsoids, N-dimensional works fine.
An STL model, i.e. mesh, is a 2-dimensional surface embedded in 3-space. There is an imagej-mesh library offering a
Mesh data structure. The main use case there is 3D graphics rendering with Scenery, SciView and friends. Currently, ImageJ’s
Mesh interface is unrelated to
RealMask, although I suppose one could create an adapter, if you wanted to use a
Mesh to define a ROI. Some technical decisions would be necessary though, like whether the mesh should be treated as hollow.
OK, I know, the standard geometry such as ball, rect box, ellipsoids could be defined well in nd. the multiline could be defined, but if you want to do a operate, such as buffer a 3d line, you will got a 3d mesh volume. So In my opinions, “Mesh is not 2d suface in 3d-space, but mesh is 3d-polygon”, And mesh can operate itself(such as count suface area, volume, and do buffer, convex hull…), and could be operate each other(clip, union, intersect…), And In general, any element should be operated eachother(nd line, nd point, nd polygon/mesh).
As I known, JTS has done most 2d operator, and it is implemented lightly and efficiently. (And some gis/geometry liberies such as arcgis/pymesh or some 3d edit software such as blender implements some 3d operator)
As your description, I think, polygon2d is very important as an arbitrary segment result, and is the most difficult part in ImageJ’s ROI model (just my guess work), I think JTS is a good solution.