use of boofcv.struct.image.ImageBase in project BoofCV by lessthanoptimal.
the class TestConvolveImage method reformatForValidation.
@Override
protected Object[] reformatForValidation(Method m, Object[] targetParam) {
Object[] ret = new Object[] { targetParam[0], targetParam[1], targetParam[2] };
ImageBase inputImage = (ImageBase) targetParam[1];
KernelBase kernel = (KernelBase) targetParam[0];
computeBorder(kernel, m.getName());
int w = borderX0 + borderX1;
int h = borderY0 + borderY1;
ret[1] = inputImage.createNew(width + w, height + h);
ret[2] = ((ImageBase) targetParam[2]).createNew(width + w, height + h);
fillTestImage(inputImage, (ImageBase) ret[1], kernel, m.getName());
return ret;
}
use of boofcv.struct.image.ImageBase in project BoofCV by lessthanoptimal.
the class TestConvolveJustBorder_General_IL method createInputParam.
@Override
protected Object[][] createInputParam(Method candidate, Method validation) {
Class<?>[] paramTypes = candidate.getParameterTypes();
KernelBase kernel = createKernel(paramTypes[0], kernelWidth, kernelWidth / 2);
ImageBase src = ConvolutionTestHelper.createImage(validation.getParameterTypes()[1], width, height);
GImageMiscOps.fillUniform(src, rand, 0, 5);
ImageBase dst = ConvolutionTestHelper.createImage(validation.getParameterTypes()[2], width, height);
Object[][] ret = new Object[2][paramTypes.length];
// normal symmetric odd kernel
ret[0][0] = kernel;
ret[0][1] = InterleavedF32.class == src.getClass() ? ImageBorderValue.wrap((InterleavedF32) src, fillValue) : ImageBorderValue.wrap((InterleavedInteger) src, fillValue);
ret[0][2] = dst;
// change the offset
kernel = createKernel(paramTypes[0], kernelWidth, kernelWidth / 2 - 1);
ret[1][0] = kernel;
ret[1][1] = InterleavedF32.class == src.getClass() ? ImageBorderValue.wrap((InterleavedF32) src, fillValue) : ImageBorderValue.wrap((InterleavedInteger) src, fillValue);
ret[1][2] = ConvolutionTestHelper.createImage(validation.getParameterTypes()[2], width, height);
return ret;
}
use of boofcv.struct.image.ImageBase in project BoofCV by lessthanoptimal.
the class TestClipAndReduce method massage_distorted.
/**
* fill the center of the image with a single color. If clipped correctly the output should be that color
* entirely. If not only the center
*/
private void massage_distorted(boolean clipped, ImageType type) {
ImageBase input = type.createImage(40, 30);
GImageMiscOps.fill(input.subimage(5, 0, 35, 30), 255);
ImageBase output = type.createImage(20, 20);
ClipAndReduce alg = new ClipAndReduce(clipped, type);
alg.massage(input, output);
if (clipped) {
assertEquals(255, GeneralizedImageOps.get(output, 0, 10, 0), 1e-4);
assertEquals(255, GeneralizedImageOps.get(output, 10, 10, 0), 1e-4);
assertEquals(255, GeneralizedImageOps.get(output, 19, 10, 0), 1e-4);
} else {
assertEquals(0, GeneralizedImageOps.get(output, 0, 10, 0), 2);
assertEquals(255, GeneralizedImageOps.get(output, 10, 10, 0), 1e-4);
assertEquals(0, GeneralizedImageOps.get(output, 19, 10, 0), 2);
}
}
use of boofcv.struct.image.ImageBase in project BoofCV by lessthanoptimal.
the class TestClipAndReduce method massage_written_to.
private void massage_written_to(boolean clipped, ImageType type) {
ImageBase input = type.createImage(40, 30);
GImageMiscOps.fillUniform(input, rand, -1, 1);
ImageBase output = type.createImage(20, 20);
ClipAndReduce alg = new ClipAndReduce(clipped, type);
alg.massage(input, output);
// make sure every pixel has been written to
for (int y = 0; y < output.height; y++) {
for (int x = 0; x < output.width; x++) {
double value = GeneralizedImageOps.get(output, x, y, 0);
assertTrue(value != 0);
}
}
}
Aggregations