use of boofcv.struct.image.ImageGray in project BoofCV by lessthanoptimal.
the class GeneralChecksInterpolationPixelMB method compareToSingleBand.
/**
* Compares interpolation to two single band images and sees if they produce nearly identical results
*/
@Test
public void compareToSingleBand() {
T origMB = createImage(30, 40, 2);
GImageMiscOps.fillUniform(origMB, rand, 0, 100);
ImageDataType dataType = origMB.getImageType().getDataType();
ImageGray band0 = GeneralizedImageOps.createSingleBand(dataType, origMB.width, origMB.height);
ImageGray band1 = GeneralizedImageOps.createSingleBand(dataType, origMB.width, origMB.height);
for (int y = 0; y < origMB.height; y++) {
for (int x = 0; x < origMB.width; x++) {
double val0 = GeneralizedImageOps.get(origMB, x, y, 0);
double val1 = GeneralizedImageOps.get(origMB, x, y, 1);
GeneralizedImageOps.set(band0, x, y, val0);
GeneralizedImageOps.set(band1, x, y, val1);
}
}
InterpolatePixelS interpBand0 = wrapSingle(band0, 0, 255);
InterpolatePixelS interpBand1 = wrapSingle(band1, 0, 255);
InterpolatePixelMB<T> interpMB = wrap(origMB, 0, 255);
interpBand0.setBorder(FactoryImageBorder.genericValue(0, band0.getImageType()));
interpBand1.setBorder(FactoryImageBorder.genericValue(0, band1.getImageType()));
interpMB.setBorder(FactoryImageBorder.genericValue(0, interpMB.getImageType()));
interpBand0.setImage(band0);
interpBand1.setImage(band1);
interpMB.setImage(origMB);
float[] values = new float[2];
for (int y = 0; y < origMB.height - 1; y++) {
for (int x = 0; x < origMB.width - 1; x++) {
float val0 = interpBand0.get(x + 0.2f, y + 0.3f);
float val1 = interpBand1.get(x + 0.2f, y + 0.3f);
interpMB.get(x + 0.2f, y + 0.3f, values);
assertEquals(val0, values[0], 1e-4f);
assertEquals(val1, values[1], 1e-4f);
}
}
}
use of boofcv.struct.image.ImageGray in project BoofCV by lessthanoptimal.
the class TestGradientToEdgeFeatures method direction.
public void direction(Method m) {
Class[] params = m.getParameterTypes();
ImageGray derivX = GeneralizedImageOps.createSingleBand(params[0], width, height);
ImageGray derivY = GeneralizedImageOps.createSingleBand(params[0], width, height);
GImageMiscOps.fillUniform(derivX, rand, 0, 10);
GImageMiscOps.fillUniform(derivY, rand, 0, 10);
BoofTesting.checkSubImage(this, "direction", true, m, derivX, derivY, intensity);
}
use of boofcv.struct.image.ImageGray in project BoofCV by lessthanoptimal.
the class TestImplEdgeNonMaxSuppressionCrude method inner.
public void inner(Method m) {
Class derivType = m.getParameterTypes()[1];
GrayF32 input = new GrayF32(width, height);
GrayF32 output = new GrayF32(width, height);
ImageGray derivX = GeneralizedImageOps.createSingleBand(derivType, width, height);
ImageGray derivY = GeneralizedImageOps.createSingleBand(derivType, width, height);
input.set(2, 2, 20);
input.set(1, 1, 30);
input.set(1, 3, 30);
input.set(3, 1, 30);
input.set(3, 3, 30);
// should not be suppressed
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
// set the direction of the gradient
GeneralizedImageOps.set(derivX, 2, 2, i * 2 - 1);
GeneralizedImageOps.set(derivY, 2, 2, j * 2 - 1);
// adjust intensity values so that they will not suppress, but any errors will cause an error
int dx = i == 0 ? -1 : 1;
int dy = j == 0 ? -1 : 1;
GeneralizedImageOps.set(input, 2 - dx, 2 - dy, 10);
GeneralizedImageOps.set(input, 2 + dx, 2 + dy, 10);
BoofTesting.checkSubImage(this, "inner", true, m, input, derivX, derivY, output, false);
GeneralizedImageOps.set(input, 2 - dx, 2 - dy, 30);
GeneralizedImageOps.set(input, 2 + dx, 2 + dy, 30);
}
}
// should be suppressed
input.set(1, 1, 10);
input.set(1, 3, 10);
input.set(3, 1, 10);
input.set(3, 3, 10);
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
// set the direction of the gradient
GeneralizedImageOps.set(derivX, 2, 2, i);
GeneralizedImageOps.set(derivY, 2, 2, j);
// adjust intensity values so that they will suppress, but any errors will cause an error
int dx = i == 0 ? -1 : 1;
int dy = j == 0 ? -1 : 1;
GeneralizedImageOps.set(input, 2 - dx, 2 - dy, 30);
GeneralizedImageOps.set(input, 2 + dx, 2 + dy, 30);
BoofTesting.checkSubImage(this, "inner", true, m, input, derivX, derivY, output, true);
GeneralizedImageOps.set(input, 2 - dx, 2 - dy, 10);
GeneralizedImageOps.set(input, 2 + dx, 2 + dy, 10);
}
}
// uniform case should be NOT suppressed
GImageMiscOps.fill(input, 2);
BoofTesting.checkSubImage(this, "inner", true, m, input, derivX, derivY, output, false);
}
use of boofcv.struct.image.ImageGray in project BoofCV by lessthanoptimal.
the class TestImplEdgeNonMaxSuppressionCrude method border.
public void border(Method m) {
Class derivType = m.getParameterTypes()[1];
GrayF32 input = new GrayF32(width, height);
GrayF32 output = new GrayF32(width, height);
ImageGray derivX = GeneralizedImageOps.createSingleBand(derivType, width, height);
ImageGray derivY = GeneralizedImageOps.createSingleBand(derivType, width, height);
BoofTesting.checkSubImage(this, "border", true, m, input, derivX, derivY, output);
}
use of boofcv.struct.image.ImageGray in project BoofCV by lessthanoptimal.
the class TestImplGradientToEdgeFeatures method intensityE.
public void intensityE(Method m) throws InvocationTargetException, IllegalAccessException {
Class derivType = m.getParameterTypes()[0];
ImageGray derivX = GeneralizedImageOps.createSingleBand(derivType, width, height);
ImageGray derivY = GeneralizedImageOps.createSingleBand(derivType, width, height);
GImageMiscOps.fillUniform(derivX, rand, -20, 20);
GImageMiscOps.fillUniform(derivY, rand, -20, 20);
GrayF32 intensity = new GrayF32(width, height);
BoofTesting.checkSubImage(this, "intensityE", false, m, derivX, derivY, intensity);
}
Aggregations