use of boofcv.struct.image.GrayU8 in project BoofCV by lessthanoptimal.
the class CompareToBinaryNaive method createInputParam.
@Override
protected Object[][] createInputParam(Method candidate, Method validation) {
GrayU8 input = new GrayU8(width, height);
GrayU8 output = new GrayU8(width, height);
ImageMiscOps.fillUniform(input, rand, 0, 1);
if (isSpecialFunction(candidate)) {
return new Object[][] { { input, 1, output } };
} else {
return new Object[][] { { input, output } };
}
}
use of boofcv.struct.image.GrayU8 in project BoofCV by lessthanoptimal.
the class TestImplMedianSortNaive method trivialTest.
@Test
public void trivialTest() {
GrayU8 templateImage = new GrayU8(4, 4);
for (int i = 0; i < templateImage.width; i++) {
for (int j = 0; j < templateImage.height; j++) {
templateImage.set(j, i, i * templateImage.width + j);
}
}
int numFound = 0;
Method[] methods = ImplMedianSortNaive.class.getMethods();
for (Method m : methods) {
if (!m.getName().equals("process"))
continue;
if (m.getParameterTypes().length != 4)
continue;
Class[] params = m.getParameterTypes();
ImageGray input = GeneralizedImageOps.createSingleBand(params[0], 4, 4);
ImageGray found = GeneralizedImageOps.createSingleBand(params[1], 4, 4);
GConvertImage.convert(templateImage, input);
BoofTesting.checkSubImage(this, "trivialTest", true, m, input, found);
numFound++;
}
assertEquals(2, numFound);
}
use of boofcv.struct.image.GrayU8 in project BoofCV by lessthanoptimal.
the class GenericThresholdCommon method widthLargerThanImage.
@Test(expected = IllegalArgumentException.class)
public void widthLargerThanImage() {
T input = GeneralizedImageOps.createSingleBand(imageType, 10, 12);
GrayU8 output = new GrayU8(10, 12);
InputToBinary<T> alg = createAlg(20, 1.0, true);
alg.process(input, output);
}
use of boofcv.struct.image.GrayU8 in project BoofCV by lessthanoptimal.
the class GenericThresholdCommon method subImage.
@Test
public void subImage() {
T input = GeneralizedImageOps.createSingleBand(imageType, 100, 120);
GImageMiscOps.fillUniform(input, rand, 0, 255);
GrayU8 expected = new GrayU8(100, 120);
T sub_input = BoofTesting.createSubImageOf(input);
GrayU8 sub_output = BoofTesting.createSubImageOf(expected);
InputToBinary<T> alg = createAlg(14, 1.0, true);
alg.process(input, expected);
alg.process(sub_input, sub_output);
BoofTesting.assertEquals(expected, sub_output, 0);
}
use of boofcv.struct.image.GrayU8 in project BoofCV by lessthanoptimal.
the class GenericThresholdCommon method toggleDown.
@Test
public void toggleDown() {
T input = GeneralizedImageOps.createSingleBand(imageType, 100, 120);
GImageMiscOps.fillUniform(input, rand, 0, 255);
GrayU8 down = new GrayU8(100, 120);
GrayU8 up = new GrayU8(100, 120);
// turn off texture so that the output's can be the inverse of each other
createAlg(6, 1.0, true).process(input, down);
createAlg(6, 1.0, false).process(input, up);
for (int y = 0; y < down.height; y++) {
for (int x = 0; x < down.width; x++) {
assertTrue(x + " " + y, (down.get(x, y) == 0) == !(up.get(x, y) == 0));
}
}
}
Aggregations