use of boofcv.core.image.GImageGray in project BoofCV by lessthanoptimal.
the class TestShrinkThresholdHard_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, a.get(x, y).floatValue(), 1e-4);
}
}
}
}
use of boofcv.core.image.GImageGray in project BoofCV by lessthanoptimal.
the class TestImageMiscOps method testCopy.
private void testCopy(Method m) throws InvocationTargetException, IllegalAccessException {
Class[] paramTypes = m.getParameterTypes();
ImageGray src = GeneralizedImageOps.createSingleBand(paramTypes[6], width, height);
ImageGray dst = GeneralizedImageOps.createSingleBand(paramTypes[7], width, height);
GImageMiscOps.fillUniform(src, rand, 0, 20);
GImageMiscOps.fillUniform(dst, rand, 0, 20);
int w = 5, h = 8;
int x0 = 1, y0 = 2;
int x1 = 3, y1 = 4;
m.invoke(null, 1, 2, 3, 4, w, h, src, dst);
GImageGray a = FactoryGImageGray.wrap(src);
GImageGray b = FactoryGImageGray.wrap(dst);
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
assertEquals(a.get(x0 + j, y0 + i).doubleValue(), b.get(x1 + j, y1 + i).doubleValue(), 1e-4);
}
}
}
use of boofcv.core.image.GImageGray in project BoofCV by lessthanoptimal.
the class TestImageMiscOps method testFillRectangle_Single.
private void testFillRectangle_Single(Method m) throws InvocationTargetException, IllegalAccessException {
Class[] paramTypes = m.getParameterTypes();
ImageGray orig = GeneralizedImageOps.createSingleBand(paramTypes[0], width, height);
int x0 = 2;
int y0 = 3;
int width = 5;
int height = 6;
if (orig.getDataType().isInteger()) {
m.invoke(null, orig, 10, x0, y0, width, height);
} else {
m.invoke(null, orig, 10.0f, x0, y0, width, height);
}
GImageGray a = FactoryGImageGray.wrap(orig);
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
if (j < x0 || i < y0 || i >= (x0 + width) || j >= (y0 + height))
assertEquals(j + " " + i, 0.0, a.get(j, i).doubleValue(), 1e-4);
else
assertEquals(10.0, a.get(j, i).doubleValue(), 1e-4);
}
}
}
use of boofcv.core.image.GImageGray in project BoofCV by lessthanoptimal.
the class TestImageMiscOps method testFill_Single.
private void testFill_Single(Method m) throws InvocationTargetException, IllegalAccessException {
Class[] paramTypes = m.getParameterTypes();
ImageGray orig = GeneralizedImageOps.createSingleBand(paramTypes[0], width, height);
GImageMiscOps.fillUniform(orig, rand, 0, 20);
if (orig.getDataType().isInteger()) {
m.invoke(null, orig, 10);
} else {
m.invoke(null, orig, 10.0f);
}
GImageGray a = FactoryGImageGray.wrap(orig);
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
assertEquals(10.0, a.get(j, i).doubleValue(), 1e-4);
}
}
}
use of boofcv.core.image.GImageGray in project BoofCV by lessthanoptimal.
the class TestImplWaveletTransformInner method equalsTranVertical.
private void equalsTranVertical(ImageGray expected, ImageGray found, int begin, int end, String quad) {
GImageGray e = FactoryGImageGray.wrap(expected);
GImageGray f = FactoryGImageGray.wrap(found);
for (int y = 0; y < expected.height; y++) {
// the border should be unmodified, zeros
if (y >= begin && y < end) {
for (int x = 0; x < expected.width; x++) {
assertEquals(quad + " ( " + x + " , " + y + " )", e.get(x, y).floatValue(), f.get(x, y).floatValue(), 1e-4f);
}
} else {
for (int x = 0; x < expected.width; x++) {
assertTrue(quad + " ( " + x + " , " + y + " ) 0 != " + f.get(x, y), 0 == f.get(x, y).floatValue());
}
}
}
}
Aggregations