NOTICE! This is a static HTML version of a legacy ImageJ Trac ticket.

The ImageJ project now uses GitHub Issues for issue tracking.

Please file all new issues there.

Ticket #581 (closed defect: fixed)

Opened 2011-06-08T10:18:38-05:00

Last modified 2011-06-21T08:25:46-05:00

OverlayTranslator does not handle "not" Rois correctly

Reported by: leek Owned by: leek
Priority: major Milestone: imagej2-b3-headless
Component: Legacy Compatibility Version:
Severity: serious Keywords:
Cc: Blocked By:
Blocking:

Description

OverlayTranslatorTest has a test which is currently not marked with @Test named "testThatWillMakeYouCry". The test creates two rois: a larger one and a second one that is inside the larger, then uses Roi.not() to create a hole in the larger one in the shape of the smaller one.

The code as it stands doesn't know how to handle this case. The code creates two polygons, but, really, there are two paths, not two polygons and the line-crossing logic correctly determines in Java that it crosses an even number of lines to get to the interior. So, you need a multi-polygon or path imglib RegionOfInterest to represent this case. The PolygonRegionOfInterest code is almost capable of this: it needs to know that the last vertex in the outer polygon closes the outer polygon instead of connecting to the first vertex in the inner polygon.

It's pretty difficult to detect that one polygon is within another, but possible. Maybe there is AWT code that can do this with the ROIs.

Change History

comment:1 Changed 2011-06-21T08:25:46-05:00 by leek

  • Status changed from new to closed
  • Resolution set to fixed

The new composite ROI handles this very nicely. It turns out that the AWT code uses the line-crossing algorithm to decide whether something is inside or outside. This translates to XORing the polygons that you get back from the ShapeROI together in the composite. This is a piece of cake since the composite ROI can be driven to do this.

So the test is renamed because it works and doesn't make me sad. It's marked as @Test now and passes just fine.