use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.
the class TestLinearContourLabelChang2004 method test1_8.
@Test
public void test1_8() {
GrayU8 input = TEST1.clone();
GrayS32 labeled = new GrayS32(input.width, input.height);
LinearContourLabelChang2004 alg = new LinearContourLabelChang2004(ConnectRule.EIGHT);
alg.process(input, labeled);
assertEquals(1, alg.getContours().size);
checkContour(alg, labeled, 8);
}
use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.
the class TestLinearContourLabelChang2004 method test3_8.
@Test
public void test3_8() {
GrayU8 input = TEST4.clone();
GrayS32 labeled = new GrayS32(input.width, input.height);
LinearContourLabelChang2004 alg = new LinearContourLabelChang2004(ConnectRule.EIGHT);
alg.process(input, labeled);
assertEquals(1, alg.getContours().size);
checkContour(alg, labeled, 8);
}
use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.
the class TestLinearContourLabelChang2004 method test2_8.
@Test
public void test2_8() {
GrayU8 input = TEST2.clone();
GrayS32 labeled = new GrayS32(input.width, input.height);
LinearContourLabelChang2004 alg = new LinearContourLabelChang2004(ConnectRule.EIGHT);
alg.process(input, labeled);
assertEquals(4, alg.getContours().size);
checkContour(alg, labeled, 8);
}
use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.
the class TestLinearContourLabelChang2004 method findContour4.
/**
* Create an unordered list of all points in the internal and external contour
*/
private List<Point2D_I32> findContour4(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(); i++) {
Point2D_I32 a = local.get(i);
if (get(border, x + a.x, y + a.y) != target) {
isContour = true;
}
}
if (isContour)
list.add(new Point2D_I32(x, y));
}
}
}
return list;
}
use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.
the class TestWaveletTransformInt method compareToWaveletTransformOps.
@Test
public void compareToWaveletTransformOps() {
GrayS32 orig = new GrayS32(width, height);
GImageMiscOps.fillUniform(orig, rand, 0, 20);
GrayS32 origCopy = orig.clone();
int N = 3;
ImageDimension dimen = UtilWavelet.transformDimension(orig, N);
GrayS32 found = new GrayS32(dimen.width, dimen.height);
GrayS32 expected = new GrayS32(dimen.width, dimen.height);
WaveletDescription<WlCoef_I32> desc = FactoryWaveletDaub.biorthogonal_I32(5, BorderType.REFLECT);
GrayS32 storage = new GrayS32(dimen.width, dimen.height);
WaveletTransformOps.transformN(desc, orig.clone(), expected, storage, N);
WaveletTransformInt<GrayS32> alg = new WaveletTransformInt<>(desc, N, 0, 255, GrayS32.class);
alg.transform(orig, found);
// make sure the original input was not modified like it is in WaveletTransformOps
BoofTesting.assertEquals(origCopy, orig, 0);
// see if the two techniques produced the same results
BoofTesting.assertEquals(expected, found, 0);
// test inverse transform
GrayS32 reconstructed = new GrayS32(width, height);
alg.invert(found, reconstructed);
BoofTesting.assertEquals(orig, reconstructed, 0);
// make sure the input has not been modified
BoofTesting.assertEquals(expected, found, 0);
}
Aggregations