use of boofcv.struct.image.GrayU8 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.GrayU8 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.GrayU8 in project BoofCV by lessthanoptimal.
the class TestThresholdImageOps method localGaussian.
@Test
public void localGaussian() {
int total = 0;
Method[] list = ThresholdImageOps.class.getMethods();
for (Method m : list) {
if (!m.getName().equals("localGaussian"))
continue;
Class[] param = m.getParameterTypes();
ImageGray input = GeneralizedImageOps.createSingleBand(param[0], width, height);
GrayU8 output = new GrayU8(width, height);
GImageMiscOps.fillUniform(input, rand, 0, 200);
BoofTesting.checkSubImage(this, "performLocalGaussian", true, m, input, output);
total++;
}
assertEquals(2, total);
}
use of boofcv.struct.image.GrayU8 in project BoofCV by lessthanoptimal.
the class TestThresholdImageOps method naiveLocalSquare.
public void naiveLocalSquare(ImageGray input, GrayU8 output, int radius, double scale, boolean down) {
ImageGray blur;
boolean isInt;
if (input instanceof GrayU8) {
isInt = true;
blur = BlurImageOps.mean((GrayU8) input, null, radius, null);
} else {
isInt = false;
blur = BlurImageOps.mean((GrayF32) input, null, radius, null);
}
float fscale = (float) scale;
for (int y = 0; y < input.height; y++) {
for (int x = 0; x < input.width; x++) {
double threshold = GeneralizedImageOps.get(blur, x, y);
double v = GeneralizedImageOps.get(input, x, y);
boolean one;
if (down) {
if (isInt) {
one = (int) v <= ((int) threshold) * fscale;
} else {
one = v <= threshold * fscale;
}
} else {
if (isInt) {
one = ((int) v) * fscale > (int) threshold;
} else {
one = v * fscale > threshold;
}
}
if (one) {
output.set(x, y, 1);
} else {
output.set(x, y, 0);
}
}
}
}
use of boofcv.struct.image.GrayU8 in project BoofCV by lessthanoptimal.
the class TestThresholdImageOps method threshold.
@Test
public void threshold() {
int total = 0;
Method[] list = ThresholdImageOps.class.getMethods();
for (Method m : list) {
if (!m.getName().equals("threshold"))
continue;
Class[] param = m.getParameterTypes();
ImageGray input = GeneralizedImageOps.createSingleBand(param[0], width, height);
GrayU8 output = new GrayU8(width, height);
GImageGray a = FactoryGImageGray.wrap(input);
for (int y = 0; y < input.height; y++) {
for (int x = 0; x < input.width; x++) {
a.set(x, y, x);
}
}
BoofTesting.checkSubImage(this, "performThreshold", true, m, input, output);
total++;
}
assertEquals(6, total);
}
Aggregations