use of boofcv.core.image.GImageGray 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);
}
use of boofcv.core.image.GImageGray in project BoofCV by lessthanoptimal.
the class TestImplMedianSortEdgeNaive method compareResults.
@Override
protected void compareResults(Object targetResult, Object[] targetParam, Object validationResult, Object[] validationParam) {
GImageGray found = FactoryGImageGray.wrap((ImageGray) targetParam[1]);
GImageGray expected = FactoryGImageGray.wrap((ImageGray) validationParam[1]);
for (int y = 0; y < height; y++) {
if (y > radius || y < height - radius)
continue;
for (int x = 0; x < width; x++) {
if (x > radius || x < width - radius)
continue;
assertEquals(found.get(x, y).intValue(), expected.get(x, y).intValue());
}
}
}
use of boofcv.core.image.GImageGray in project BoofCV by lessthanoptimal.
the class TestImplGrayImageOps method stretch.
public void stretch(Method m) throws InvocationTargetException, IllegalAccessException {
Class[] param = m.getParameterTypes();
ImageGray input = GeneralizedImageOps.createSingleBand(param[0], width, height);
ImageGray output = GeneralizedImageOps.createSingleBand(param[0], width, height);
GImageMiscOps.fill(input, 23);
m.invoke(null, input, 2.5, 10, 255, output);
GImageGray b = FactoryGImageGray.wrap(output);
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
if (output.getDataType().isInteger())
assertEquals(67, b.get(x, y).doubleValue(), 1e-4);
else
assertEquals(67.5, b.get(x, y).doubleValue(), 1e-4);
}
}
// check to see how well it sets the ceiling
m.invoke(null, input, 10, 28, 255, output);
assertEquals(255, b.get(5, 6).doubleValue(), 1e-4);
// check it flooring to zero
m.invoke(null, input, -1, 2, 255, output);
assertEquals(0, b.get(5, 6).doubleValue(), 1e-4);
}
use of boofcv.core.image.GImageGray in project BoofCV by lessthanoptimal.
the class TestImplGrayImageOps method invert.
public void invert(Method m) throws InvocationTargetException, IllegalAccessException {
Class[] param = m.getParameterTypes();
ImageGray input = GeneralizedImageOps.createSingleBand(param[0], width, height);
GImageMiscOps.fillUniform(input, rand, 0, 100);
ImageGray output = GeneralizedImageOps.createSingleBand(param[0], width, height);
m.invoke(null, input, 255, output);
GImageGray a = FactoryGImageGray.wrap(input);
GImageGray b = FactoryGImageGray.wrap(output);
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
assertEquals(255 - a.get(x, y).doubleValue(), b.get(x, y).doubleValue(), 1e-4f);
}
}
}
use of boofcv.core.image.GImageGray in project BoofCV by lessthanoptimal.
the class TestShrinkThresholdSoft_I32 method performBasicSoftTest.
public static <T extends ImageGray<T>> void performBasicSoftTest(T image, ShrinkThresholdRule<T> rule) {
final int height = image.height;
final int width = image.width;
GImageGray a = FactoryGImageGray.wrap(image);
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
a.set(x, y, x);
}
}
rule.process(image, 4);
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
if (x < 4) {
assertEquals(0, a.get(x, y).floatValue(), 1e-4);
} else {
assertEquals(x - 4, a.get(x, y).floatValue(), 1e-4);
}
}
}
}
Aggregations