use of boofcv.struct.image.ImageGray in project BoofCV by lessthanoptimal.
the class TestImageMiscOps method testFillGaussian_Single.
private void testFillGaussian_Single(Method m) throws InvocationTargetException, IllegalAccessException {
Class[] paramTypes = m.getParameterTypes();
ImageGray orig = GeneralizedImageOps.createSingleBand(paramTypes[0], width, height);
if (orig.getDataType().isSigned())
m.invoke(null, orig, rand, 0, 5, -2, 2);
else {
m.invoke(null, orig, rand, 5, 7, 0, 12);
}
int numZero = 0;
GImageGray a = FactoryGImageGray.wrap(orig);
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
double value = a.get(j, i).doubleValue();
if (orig.getDataType().isSigned()) {
assertTrue("value = " + value, value >= -2 && value <= 2);
} else {
assertTrue("value = " + value, value >= 0 && value <= 12);
}
if (value == 0)
numZero++;
}
}
assertTrue(numZero < width * height);
}
use of boofcv.struct.image.ImageGray in project BoofCV by lessthanoptimal.
the class TestImageMiscOps method testAddUniform_Single.
private void testAddUniform_Single(Method m) throws InvocationTargetException, IllegalAccessException {
Class[] paramTypes = m.getParameterTypes();
ImageGray orig = GeneralizedImageOps.createSingleBand(paramTypes[0], width, height);
GImageMiscOps.fill(orig, 1);
if (orig.getDataType().isInteger()) {
m.invoke(null, orig, rand, 1, 10);
} else {
m.invoke(null, orig, rand, 1, 10);
}
GImageGray a = FactoryGImageGray.wrap(orig);
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
double value = a.get(j, i).doubleValue();
assertTrue(value >= -2 && value <= 11);
}
}
}
use of boofcv.struct.image.ImageGray in project BoofCV by lessthanoptimal.
the class TestImageMiscOps method testRotateCW_one.
public void testRotateCW_one(Method m) throws InvocationTargetException, IllegalAccessException {
Class[] paramTypes = m.getParameterTypes();
// test even and odd width
for (int i = 0; i < 2; i++) {
int w = 6 + i;
ImageGray orig = GeneralizedImageOps.createSingleBand(paramTypes[0], w, w);
GImageMiscOps.fillUniform(orig, rand, 0, 10);
ImageGray rotated = (ImageGray) orig.clone();
m.invoke(null, rotated);
for (int y = 0; y < w; y++) {
for (int x = 0; x < w; x++) {
double expected = GeneralizedImageOps.get(orig, x, y);
double found = GeneralizedImageOps.get(rotated, w - y - 1, x);
assertEquals(x + " " + y, expected, found, 1e-8);
}
}
}
}
use of boofcv.struct.image.ImageGray in project BoofCV by lessthanoptimal.
the class TestImageMiscOps method testFlipHorizontal.
private void testFlipHorizontal(Method m, int width) throws IllegalAccessException, InvocationTargetException {
Class[] paramTypes = m.getParameterTypes();
ImageGray imgA = GeneralizedImageOps.createSingleBand(paramTypes[0], width, height);
GImageMiscOps.fillUniform(imgA, rand, 0, 100);
ImageGray imgB = (ImageGray) imgA.clone();
m.invoke(null, imgB);
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
double valA = GeneralizedImageOps.get(imgA, width - x - 1, y);
double valB = GeneralizedImageOps.get(imgB, x, y);
assertTrue(valA == valB);
}
}
}
use of boofcv.struct.image.ImageGray in project BoofCV by lessthanoptimal.
the class TestImageMiscOps method testRotateCCW_one.
public void testRotateCCW_one(Method m) throws InvocationTargetException, IllegalAccessException {
Class[] paramTypes = m.getParameterTypes();
// test even and odd width
for (int i = 0; i < 2; i++) {
int w = 6 + i;
ImageGray orig = GeneralizedImageOps.createSingleBand(paramTypes[0], w, w);
GImageMiscOps.fillUniform(orig, rand, 0, 10);
ImageGray rotated = (ImageGray) orig.clone();
m.invoke(null, rotated);
for (int y = 0; y < w; y++) {
for (int x = 0; x < w; x++) {
double expected = GeneralizedImageOps.get(orig, x, y);
double found = GeneralizedImageOps.get(rotated, y, w - x - 1);
assertEquals(expected, found, 1e-8);
}
}
}
}
Aggregations