use of net.imglib2.RealPoint in project imagej-ops by imagej.
the class PolygonFeatureTests method centroid.
@Test
public void centroid() {
// ground truth computed with matlab
final RealPoint expected = new RealPoint(38.144483985765, 59.404175563464);
final RealPoint result = (RealPoint) ops.run(CentroidPolygon.class, contour);
assertEquals("Centroid X", expected.getDoublePosition(0), result.getDoublePosition(0), EPSILON);
assertEquals("Centroid Y", expected.getDoublePosition(1), result.getDoublePosition(1), EPSILON);
}
use of net.imglib2.RealPoint in project imagej-ops by imagej.
the class AbstractFeatureTest method getPolygon.
protected static Polygon2D getPolygon() {
final List<RealPoint> vertices = new ArrayList<>();
try {
Files.lines(Paths.get(AbstractFeatureTest.class.getResource("2d_geometric_features_polygon.txt").toURI())).forEach(l -> {
String[] coord = l.split(" ");
RealPoint v = new RealPoint(new double[] { Double.parseDouble(coord[0]), Double.parseDouble(coord[1]) });
vertices.add(v);
});
} catch (IOException | URISyntaxException exc) {
exc.printStackTrace();
}
return new DefaultWritablePolygon2D(vertices);
}
Aggregations