/** Tests contours with zero and one points in them */ @Test public void checkZeroOne() { List<Point2D_I32> contour = new ArrayList<Point2D_I32>(); SplitMergeLineFitSegment alg = new SplitMergeLineFitSegment(0.1, 0.3, 100); alg.process(contour); assertEquals(0, alg.getSplits().size); contour.add(new Point2D_I32(2, 3)); alg.process(contour); assertEquals(0, alg.getSplits().size); }
/** Simple case with a zig-zag pattern */ @Test public void simpleCase() { List<Point2D_I32> contour = new ArrayList<Point2D_I32>(); for (int i = 0; i < 10; i++) contour.add(new Point2D_I32(i, 0)); for (int i = 1; i < 5; i++) contour.add(new Point2D_I32(9, i)); for (int i = 1; i < 10; i++) contour.add(new Point2D_I32(9 + i, 4)); for (int i = 2; i < 5; i++) contour.add(new Point2D_I32(18, 5 - i)); SplitMergeLineFitSegment alg = new SplitMergeLineFitSegment(0.1, 0.1, 100); alg.process(contour); GrowQueue_I32 splits = alg.getSplits(); assertEquals(5, splits.size); assertEquals(0, alg.splits.data[0]); assertEquals(9, alg.splits.data[1]); assertEquals(13, alg.splits.data[2]); assertEquals(22, alg.splits.data[3]); assertEquals(25, alg.splits.data[4]); }