Ticket #581 (closed defect: fixed)

Opened 8 years ago

Last modified 8 years ago

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 8 years ago 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.

Note: See TracTickets for help on using tickets.