use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.
the class TestContourTracer method interior1.
@Test
public void interior1() {
String s = "01110\n" + "01101\n" + "11110\n";
GrayU8 input = stringToImage(s);
GrayS32 label = new GrayS32(input.width, input.height);
ContourTracer alg = new ContourTracer(ConnectRule.EIGHT);
// process the image
alg.setInputs(addBorder(input), label, queue);
queue.grow();
alg.trace(2, 3 + 1, 0 + 1, false);
assertEquals(4, queue.sizeOfTail());
}
use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.
the class TestLinearContourLabelChang2004 method test2_4.
@Test
public void test2_4() {
GrayU8 input = TEST2.clone();
GrayS32 labeled = new GrayS32(input.width, input.height);
LinearContourLabelChang2004 alg = new LinearContourLabelChang2004(ConnectRule.FOUR);
alg.process(input, labeled);
assertEquals(14, alg.getContours().size);
checkContour(alg, labeled, 4);
}
use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.
the class TestLinearContourLabelChang2004 method test1_4.
@Test
public void test1_4() {
GrayU8 input = TEST1.clone();
GrayS32 labeled = new GrayS32(input.width, input.height);
LinearContourLabelChang2004 alg = new LinearContourLabelChang2004(ConnectRule.FOUR);
alg.process(input, labeled);
assertEquals(2, alg.getContours().size);
checkContour(alg, labeled, 4);
}
use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.
the class TestLinearContourLabelChang2004 method test3_4.
@Test
public void test3_4() {
GrayU8 input = TEST4.clone();
GrayS32 labeled = new GrayS32(input.width, input.height);
LinearContourLabelChang2004 alg = new LinearContourLabelChang2004(ConnectRule.FOUR);
alg.process(input, labeled);
assertEquals(1, alg.getContours().size);
checkContour(alg, labeled, 4);
}
use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.
the class TestLinearContourLabelChang2004 method findContour8.
/**
* Create an unordered list of all points in the internal and external contour
*/
private List<Point2D_I32> findContour8(GrayS32 labeled, int target) {
List<Point2D_I32> list = new ArrayList<>();
ImageBorder<GrayS32> border = FactoryImageBorder.singleValue(labeled, 0);
for (int y = 0; y < labeled.height; y++) {
for (int x = 0; x < labeled.width; x++) {
if (target == labeled.get(x, y)) {
boolean isContour = false;
for (int i = 0; i < local.size() - 1; i++) {
Point2D_I32 a = local.get(i);
Point2D_I32 b = local.get(i + 1);
if (get(border, x + a.x, y + a.y) != target && get(border, x + b.x, y + b.y) != target) {
isContour = true;
break;
}
}
if (!isContour && get(border, x + 1, y) != target)
isContour = true;
if (!isContour && get(border, x - 1, y) != target)
isContour = true;
if (!isContour && get(border, x, y + 1) != target)
isContour = true;
if (!isContour && get(border, x, y - 1) != target)
isContour = true;
if (isContour)
list.add(new Point2D_I32(x, y));
}
}
}
return list;
}
Aggregations