use of net.imagej.ops.geom.geom2d.LabelRegionToPolygonConverter in project imagej-ops by imagej.
the class PolygonFeatureTests method labelRegionToPolygonConverter.
@Test
public void labelRegionToPolygonConverter() {
// ground truth computed with matlab
final LabelRegionToPolygonConverter c = new LabelRegionToPolygonConverter();
c.setContext(ops.context());
final Polygon2D test = c.convert(ROI, Polygon2D.class);
final List<? extends RealLocalizable> expected = GeomUtils.vertices(contour);
final List<? extends RealLocalizable> received = GeomUtils.vertices(test);
assertEquals("Number of polygon points differs.", expected.size(), received.size());
for (int i = 0; i < contour.numVertices(); i++) {
assertEquals("Polygon point " + i + " differs in x-coordinate.", expected.get(i).getDoublePosition(0), received.get(i).getDoublePosition(0), EPSILON);
assertEquals("Polygon point " + i + " differs in y-coordinate.", expected.get(i).getDoublePosition(1), received.get(i).getDoublePosition(1), EPSILON);
}
}
Aggregations