use of boofcv.struct.image.ImageInterleaved in project BoofCV by lessthanoptimal.
the class TestImageMiscOps method testFillBand.
private void testFillBand(Method m) throws InvocationTargetException, IllegalAccessException {
Class[] paramTypes = m.getParameterTypes();
ImageInterleaved orig = GeneralizedImageOps.createInterleaved(paramTypes[0], width, height, numBands);
for (int band = 0; band < numBands; band++) {
GImageMiscOps.fillUniform(orig, rand, 0, 20);
if (orig.getDataType().isInteger()) {
m.invoke(null, orig, band, 10);
} else {
m.invoke(null, orig, band, 10.0f);
}
int numMatch = 0;
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
for (int k = 0; k < numBands; k++) {
double value = GeneralizedImageOps.get(orig, j, i, k);
if (k == band) {
assertEquals(10.0, value, 1e-4);
} else {
if (10.0 == value)
numMatch++;
}
}
}
}
assertFalse(numMatch > width * height * (numBands - 1) / 5);
}
}
use of boofcv.struct.image.ImageInterleaved in project BoofCV by lessthanoptimal.
the class TestImageMiscOps method testFill_Interleaved.
private void testFill_Interleaved(Method m) throws InvocationTargetException, IllegalAccessException {
Class[] paramTypes = m.getParameterTypes();
ImageInterleaved orig = GeneralizedImageOps.createInterleaved(paramTypes[0], width, height, numBands);
GImageMiscOps.fillUniform(orig, rand, 0, 20);
if (orig.getDataType().isInteger()) {
m.invoke(null, orig, 10);
} else {
m.invoke(null, orig, 10.0f);
}
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
for (int band = 0; band < numBands; band++) {
double value = GeneralizedImageOps.get(orig, j, i, band);
assertEquals(10.0, value, 1e-4);
}
}
}
}
use of boofcv.struct.image.ImageInterleaved in project BoofCV by lessthanoptimal.
the class TestImageMiscOps method testFill_Interleaved_array.
private void testFill_Interleaved_array(Method m) throws InvocationTargetException, IllegalAccessException {
Class[] paramTypes = m.getParameterTypes();
ImageInterleaved orig = GeneralizedImageOps.createInterleaved(paramTypes[0], width, height, numBands);
GImageMiscOps.fillUniform(orig, rand, 0, 20);
Object array = Array.newInstance(paramTypes[1].getComponentType(), numBands);
for (int i = 0; i < numBands; i++) {
Array.set(array, i, 2 * i + 1);
}
m.invoke(null, orig, array);
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
for (int band = 0; band < numBands; band++) {
double value = GeneralizedImageOps.get(orig, j, i, band);
assertEquals(2 * band + 1, value, 1e-4);
}
}
}
}
use of boofcv.struct.image.ImageInterleaved in project BoofCV by lessthanoptimal.
the class TestImageMiscOps method testFillGaussian_Interleaved.
private void testFillGaussian_Interleaved(Method m) throws InvocationTargetException, IllegalAccessException {
Class[] paramTypes = m.getParameterTypes();
ImageInterleaved orig = GeneralizedImageOps.createInterleaved(paramTypes[0], width, height, 2);
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;
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
for (int band = 0; band < orig.numBands; band++) {
double value = GeneralizedImageOps.get(orig, j, i, band);
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 * 2);
}
use of boofcv.struct.image.ImageInterleaved in project BoofCV by lessthanoptimal.
the class TestImageMiscOps method testInsertBand.
private void testInsertBand(Method m) throws InvocationTargetException, IllegalAccessException {
Class[] paramTypes = m.getParameterTypes();
ImageGray input = GeneralizedImageOps.createSingleBand(paramTypes[0], width, height);
ImageInterleaved output = GeneralizedImageOps.createInterleaved(paramTypes[2], width, height, numBands);
GImageMiscOps.fillUniform(input, rand, 0, 20);
for (int band = 0; band < numBands; band++) {
GImageMiscOps.fillUniform(output, rand, 0, 20);
m.invoke(null, input, band, output);
int numMatch = 0;
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
double valueIn = GeneralizedImageOps.get(input, j, i);
for (int k = 0; k < numBands; k++) {
double valueOut = GeneralizedImageOps.get(output, j, i, k);
if (k == band) {
assertEquals(valueIn, valueOut, 1e-4);
} else {
if (valueIn == valueOut)
numMatch++;
}
}
}
}
assertFalse(numMatch > width * height * (numBands - 1) / 5);
}
}
Aggregations