use of boofcv.struct.border.ImageBorder in project BoofCV by lessthanoptimal.
the class TestImplCensusTransformBorder method sample_compare5x5.
@Test
void sample_compare5x5() {
Random rand = new Random(234);
for (ImageType type : new ImageType[] { ImageType.SB_U8, ImageType.SB_F32 }) {
ImageGray input = (ImageGray) type.createImage(w, h);
InterleavedU16 found = new InterleavedU16(w, h, 2);
InterleavedU16 expected = new InterleavedU16(w, h, 2);
ImageBorder border = FactoryImageBorder.wrap(BorderType.EXTENDED, input);
DogArray<Point2D_I32> samples5x5 = createSamples(2);
if (type.getDataType().isInteger()) {
GImageMiscOps.fillUniform(input, rand, 0, 255);
ImplCensusTransformBorder.sample_IU16((ImageBorder_S32) border, 2, samples5x5, found);
} else {
GImageMiscOps.fillUniform(input, rand, -2, 2);
ImplCensusTransformBorder.sample_IU16((ImageBorder_F32) border, 2, samples5x5, found);
}
CensusNaive.sample(input, samples5x5, expected);
BoofTesting.assertEqualsBorder(expected, found, 0.0, 2, 2);
}
}
use of boofcv.struct.border.ImageBorder in project BoofCV by lessthanoptimal.
the class TestInterpolatePixel_S_to_MB method checkFunctions.
@Test
void checkFunctions() {
Helper helper = new Helper();
InterpolatePixelMB alg = new InterpolatePixel_S_to_MB(helper);
float[] pixel = new float[1];
assertEquals(1, alg.getImageType().getNumBands());
alg.get(2, 3, pixel);
assertEquals(2, pixel[0], 1e-8);
alg.get_fast(2, 3, pixel);
assertEquals(3, pixel[0], 1e-8);
assertTrue(alg.isInFastBounds(20, 4));
assertFalse(alg.isInFastBounds(0, 4));
assertEquals(10, alg.getFastBorderX());
assertEquals(11, alg.getFastBorderY());
ImageBorder border = FactoryImageBorder.genericValue(0, alg.getImageType());
alg.setBorder(border);
assertTrue(border == alg.getBorder());
}
use of boofcv.struct.border.ImageBorder in project BoofCV by lessthanoptimal.
the class TestConvolveImageBox method reformatForValidation.
@Override
protected Object[] reformatForValidation(Method m, Object[] targetParam) {
Class<?>[] params = m.getParameterTypes();
Object kernel = TestConvolveImageBox.createTableKernel(params[0], kernelRadius, rand);
ImageGray output = (ImageGray) ((ImageGray) targetParam[1]).clone();
ImageBorder border = output.getDataType().isInteger() ? new ImageBorderValue.Value_I(0) : new ImageBorderValue.Value_F32(0);
return new Object[] { kernel, targetParam[0], output, border };
}
use of boofcv.struct.border.ImageBorder in project BoofCV by lessthanoptimal.
the class TestConvolveJustBorder_General_SB method reformatForValidation.
@Override
protected Object[] reformatForValidation(Method m, Object[] targetParam) {
Object[] ret = new Object[Math.max(m.getParameterTypes().length, targetParam.length)];
System.arraycopy(targetParam, 0, ret, 0, targetParam.length);
ImageBorder border = (ImageBorder) targetParam[1];
ImageGray inputImage = (ImageGray) border.getImage();
KernelBase kernel = (KernelBase) targetParam[0];
computeBorder(kernel, m.getName());
int borderWidthX = borderX0 + borderX1;
int borderWidthY = borderY0 + borderY1;
// input image
ret[1] = inputImage.createNew(width + borderWidthX, height + borderWidthY);
// output image
ret[2] = ((ImageGray) targetParam[2]).createNew(width + borderWidthX, height + borderWidthY);
GImageMiscOps.growBorder(inputImage, border, borderX0, borderY0, borderX1, borderY1, (ImageBase) ret[1]);
return ret;
}
Aggregations