use of boofcv.struct.border.ImageBorder in project BoofCV by lessthanoptimal.
the class TestImplImageMiscOps method testCopy_Border_Gray.
private void testCopy_Border_Gray(Method m) throws InvocationTargetException, IllegalAccessException {
Class[] paramTypes = m.getParameterTypes();
ImageGray src = GeneralizedImageOps.createSingleBand(paramTypes[6], width, height);
ImageBorder border = FactoryImageBorder.generic(BorderType.WRAP, src.getImageType());
ImageGray dst = GeneralizedImageOps.createSingleBand(paramTypes[8], width + 3, height + 2);
GImageMiscOps.fillUniform(src, rand, 0, 20);
GImageMiscOps.fillUniform(dst, rand, 0, 20);
// normal copy all inside
srcCopy_Border_Gray(m, src, border, dst, 5, 8, 1, 2, 3, 4);
// copy reader is larger and contains all of src
srcCopy_Border_Gray(m, src, border, dst, width + 2, height + 2, -1, -1, 0, 0);
// corner copy
srcCopy_Border_Gray(m, src, border, dst, 5, 6, -3, -2, 1, 2);
}
use of boofcv.struct.border.ImageBorder in project BoofCV by lessthanoptimal.
the class TestImplImageMiscOps method testGrowBorder.
private void testGrowBorder(Method m) throws InvocationTargetException, IllegalAccessException {
Class[] paramTypes = m.getParameterTypes();
ImageGray src = GeneralizedImageOps.createSingleBand(paramTypes[0], width, height);
ImageGray dst = GeneralizedImageOps.createSingleBand(paramTypes[6], 1, 1);
ImageBorder extend = FactoryImageBorder.generic(BorderType.EXTENDED, src.getImageType());
int borderX0 = 2;
int borderX1 = 3;
int borderY0 = 3;
int borderY1 = 2;
GImageMiscOps.fillUniform(src, rand, 0, 100);
m.invoke(null, src, extend, borderX0, borderX1, borderY0, borderY1, dst);
assertEquals(width + borderX0 + borderX1, dst.width);
assertEquals(height + borderY0 + borderY1, dst.height);
for (int y = 0; y < dst.height; y++) {
int yy = Math.min(src.height - 1, Math.max(0, y - borderY0));
for (int x = 0; x < dst.width; x++) {
int xx = Math.min(src.width - 1, Math.max(0, x - borderX0));
// manually do the extend border
double expected = GeneralizedImageOps.get(src, xx, yy);
double found = GeneralizedImageOps.get(dst, x, y);
assertEquals(expected, found, UtilEjml.TEST_F64, x + " " + y);
}
}
}
use of boofcv.struct.border.ImageBorder in project BoofCV by lessthanoptimal.
the class TestImplCensusTransformBorder method region3x3.
@Test
void region3x3() {
Random rand = new Random(234);
for (ImageType type : new ImageType[] { ImageType.SB_U8, ImageType.SB_F32 }) {
ImageGray input = (ImageGray) type.createImage(w, h);
var found = new GrayU8(w, h);
var expected = new GrayU8(w, h);
ImageBorder border = FactoryImageBorder.wrap(BorderType.EXTENDED, input);
if (type.getDataType().isInteger()) {
GImageMiscOps.fillUniform(input, rand, 0, 255);
ImplCensusTransformBorder.dense3x3_U8((ImageBorder_S32) border, found);
} else {
GImageMiscOps.fillUniform(input, rand, -2, 2);
ImplCensusTransformBorder.dense3x3_F32((ImageBorder_F32) border, found);
}
CensusNaive.region3x3(input, expected);
BoofTesting.assertEqualsBorder(expected, found, 0, 1, 1);
}
}
use of boofcv.struct.border.ImageBorder in project BoofCV by lessthanoptimal.
the class TestImplCensusTransformBorder method sample_U64.
@Test
void sample_U64() {
Random rand = new Random(234);
int r = 3;
for (ImageType type : new ImageType[] { ImageType.SB_U8, ImageType.SB_F32 }) {
ImageGray input = (ImageGray) type.createImage(w, h);
var found = new GrayS64(w, h);
var expected = new GrayS64(w, h);
ImageBorder border = FactoryImageBorder.wrap(BorderType.EXTENDED, input);
DogArray<Point2D_I32> samples = createSamples(r);
if (type.getDataType().isInteger()) {
GImageMiscOps.fillUniform(input, rand, 0, 255);
ImplCensusTransformBorder.sample_S64((ImageBorder_S32) border, r, samples, found);
} else {
GImageMiscOps.fillUniform(input, rand, -2, 2);
ImplCensusTransformBorder.sample_S64((ImageBorder_F32) border, r, samples, found);
}
CensusNaive.sample(input, samples, expected);
BoofTesting.assertEqualsBorder(expected, found, 0, r, r);
}
}
use of boofcv.struct.border.ImageBorder in project BoofCV by lessthanoptimal.
the class TestImplCensusTransformBorder method region5x5.
@Test
void region5x5() {
Random rand = new Random(234);
for (ImageType type : new ImageType[] { ImageType.SB_U8, ImageType.SB_F32 }) {
ImageGray input = (ImageGray) type.createImage(w, h);
var found = new GrayS32(w, h);
var expected = new GrayS32(w, h);
ImageBorder border = FactoryImageBorder.wrap(BorderType.EXTENDED, input);
if (type.getDataType().isInteger()) {
GImageMiscOps.fillUniform(input, rand, 0, 255);
ImplCensusTransformBorder.dense5x5_U8((ImageBorder_S32) border, found);
} else {
GImageMiscOps.fillUniform(input, rand, -2, 2);
ImplCensusTransformBorder.dense5x5_F32((ImageBorder_F32) border, found);
}
CensusNaive.region5x5(input, expected);
BoofTesting.assertEqualsBorder(expected, found, 0, 2, 2);
}
}
Aggregations