use of boofcv.struct.image.GrayF32 in project BoofCV by lessthanoptimal.
the class TestPyramidFloatScale method update.
/**
* Compares update to a convolution and sub-sampling of upper layers.
*/
@Test
public void update() {
GrayF32 input = new GrayF32(width, height);
BoofTesting.checkSubImage(this, "_update", true, input);
}
use of boofcv.struct.image.GrayF32 in project BoofCV by lessthanoptimal.
the class TestGPixelMath method all_planar_images.
/**
* Tests all functions with inputs from planar images
*/
@Test
public void all_planar_images() {
int total = 0;
Method[] methods = GPixelMath.class.getMethods();
for (Method m : methods) {
if (!Modifier.isStatic(m.getModifiers()))
continue;
Class[] param = m.getParameterTypes();
if (param.length < 1)
continue;
// create input arguments
Object[] inputs = new Object[param.length];
for (int i = 0; i < inputs.length; i++) {
if (param[i] == ImageBase.class) {
inputs[i] = new Planar(GrayF32.class, width, height, 2);
GImageMiscOps.fillUniform((ImageBase) inputs[i], rand, -100, 100);
}
}
// specialized inputs for individual functions
String name = m.getName();
if (name.equals("divide") && param.length == 3) {
if (!ImageBase.class.isAssignableFrom(param[1])) {
inputs[1] = 3;
}
} else if (name.equals("divide") && param.length == 5) {
inputs[1] = 3;
inputs[2] = -1;
inputs[3] = 5;
} else if (name.equals("multiply") && param.length == 3) {
if (!ImageBase.class.isAssignableFrom(param[1])) {
inputs[1] = 3;
}
} else if (name.equals("multiply") && param.length == 5) {
inputs[1] = 3;
inputs[2] = -20;
inputs[3] = 12;
} else if (name.equals("plus") && param.length == 3) {
inputs[1] = 3;
} else if (name.equals("plus") && param.length == 5) {
inputs[1] = 3;
inputs[2] = -10;
inputs[3] = 12;
} else if (name.equals("minus") && param.length == 3) {
boolean first = ImageBase.class.isAssignableFrom(param[0]);
inputs[first ? 1 : 0] = 3;
} else if (name.equals("minus") && param.length == 5) {
boolean first = ImageBase.class.isAssignableFrom(param[0]);
inputs[first ? 1 : 0] = 3;
inputs[2] = -10;
inputs[3] = 12;
} else if (name.equals("boundImage")) {
inputs[1] = 2;
inputs[2] = 8;
} else if (name.equals("averageBand")) {
continue;
}
try {
// create the expected results
Object[] inputsByBand = copy(inputs);
invokeByBand(m, inputsByBand);
// invoke this function
m.invoke(null, inputs);
// compare against each other
for (int i = 0; i < inputs.length; i++) {
if (Planar.class == inputs[i].getClass()) {
BoofTesting.assertEquals((ImageBase) inputs[i], (ImageBase) inputsByBand[i], 1e-4);
}
}
total++;
} catch (IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException(e);
}
}
assertEquals(21, total);
}
use of boofcv.struct.image.GrayF32 in project BoofCV by lessthanoptimal.
the class GeneralBilinearRectangleChecks method region.
public void region(T img) {
InterpolatePixelS<T> interpPt = createPixelInterpolate();
InterpolateRectangle<T> interp = createRectangleInterpolate();
interp.setImage(img);
interpPt.setImage(img);
GrayF32 out = new GrayF32(regionWidth, regionHeight);
interp.region(tl_x, tl_y, out);
for (int y = 0; y < regionHeight; y++) {
for (int x = 0; x < regionWidth; x++) {
assertEquals("( " + x + " , " + y + " )", interpPt.get(x + tl_x, y + tl_y), out.get(x, y), 1e-4);
}
}
}
use of boofcv.struct.image.GrayF32 in project BoofCV by lessthanoptimal.
the class GeneralBilinearRectangleChecks method outsideImageBorder1_barely.
@Test(expected = IllegalArgumentException.class)
public void outsideImageBorder1_barely() {
T img = createImage(20, 25);
InterpolateRectangle<T> interp = createRectangleInterpolate();
interp.setImage(img);
GrayF32 out = new GrayF32(20, 25);
interp.region(-0.1f, -0.1f, out);
}
use of boofcv.struct.image.GrayF32 in project BoofCV by lessthanoptimal.
the class TestImplWaveletTransformNaive method testEncodeDecode_F32.
private void testEncodeDecode_F32(int widthOrig, int heightOrig, int widthOut, int heightOut) {
GrayF32 orig = new GrayF32(widthOrig, heightOrig);
ImageMiscOps.fillUniform(orig, rand, 0, 30);
GrayF32 transformed = new GrayF32(widthOut, heightOut);
GrayF32 reconstructed = new GrayF32(widthOrig, heightOrig);
BoofTesting.checkSubImage(this, "checkTransforms_F32", true, orig, transformed, reconstructed);
}
Aggregations