use of boofcv.struct.border.ImageBorder_F32 in project BoofCV by lessthanoptimal.
the class TestGradientScharr method compareToConvolve_F32.
@Test
void compareToConvolve_F32() throws NoSuchMethodException {
CompareDerivativeToConvolution validator = new CompareDerivativeToConvolution();
validator.setTarget(GradientScharr.class.getMethod("process", GrayF32.class, GrayF32.class, GrayF32.class, ImageBorder_F32.class));
validator.setKernel(0, GradientScharr.kernelDerivX_F32);
validator.setKernel(1, GradientScharr.kernelDerivY_F32);
GrayF32 input = new GrayF32(width, height);
ImageMiscOps.fillUniform(input, rand, 0, 10);
GrayF32 derivX = new GrayF32(width, height);
GrayF32 derivY = new GrayF32(width, height);
validator.compare(input, derivX, derivY);
}
use of boofcv.struct.border.ImageBorder_F32 in project BoofCV by lessthanoptimal.
the class TestGradientThree method compareToConvolve_F32.
@Test
public void compareToConvolve_F32() throws NoSuchMethodException {
CompareDerivativeToConvolution validator = new CompareDerivativeToConvolution();
validator.setTarget(GradientThree.class.getMethod("process", GrayF32.class, GrayF32.class, GrayF32.class, ImageBorder_F32.class));
validator.setKernel(0, GradientThree.kernelDeriv_F32, true);
validator.setKernel(1, GradientThree.kernelDeriv_F32, false);
GrayF32 input = new GrayF32(width, height);
ImageMiscOps.fillUniform(input, rand, 0, 10);
GrayF32 derivX = new GrayF32(width, height);
GrayF32 derivY = new GrayF32(width, height);
validator.compare(input, derivX, derivY);
}
use of boofcv.struct.border.ImageBorder_F32 in project BoofCV by lessthanoptimal.
the class TestHessianFromGradient method hessianSobel_F32.
@Test
void hessianSobel_F32() throws NoSuchMethodException {
CompareHessianToConvolution validator = new CompareHessianToConvolution();
validator.setTarget(HessianFromGradient.class.getMethod("hessianSobel", GrayF32.class, GrayF32.class, GrayF32.class, GrayF32.class, GrayF32.class, ImageBorder_F32.class));
validator.setKernel(0, GradientSobel.kernelDerivX_F32);
validator.setKernel(1, GradientSobel.kernelDerivY_F32);
GrayF32 derivX = new GrayF32(width, height);
GrayF32 derivY = new GrayF32(width, height);
ImageMiscOps.fillUniform(derivX, rand, -10, 10);
ImageMiscOps.fillUniform(derivY, rand, -10, 10);
GrayF32 derivXX = new GrayF32(width, height);
GrayF32 derivYY = new GrayF32(width, height);
GrayF32 derivXY = new GrayF32(width, height);
validator.compare(derivX, derivY, derivXX, derivYY, derivXY);
}
use of boofcv.struct.border.ImageBorder_F32 in project BoofCV by lessthanoptimal.
the class FeaturePyramid method findLocalScaleSpaceMax.
/**
* Searches the pyramid layers up and down to see if the found 2D features are also scale space maximums.
*/
protected void findLocalScaleSpaceMax(PyramidFloat<T> ss, int layerID) {
int index0 = spaceIndex;
int index1 = (spaceIndex + 1) % 3;
int index2 = (spaceIndex + 2) % 3;
List<Point2D_I16> candidates = maximums[index1];
ImageBorder_F32 inten0 = FactoryImageBorderAlgs.value(intensities[index0], 0);
GrayF32 inten1 = intensities[index1];
ImageBorder_F32 inten2 = FactoryImageBorderAlgs.value(intensities[index2], 0);
float scale0 = (float) ss.scale[layerID - 1];
float scale1 = (float) ss.scale[layerID];
float scale2 = (float) ss.scale[layerID + 1];
float sigma0 = (float) ss.getSigma(layerID - 1);
float sigma1 = (float) ss.getSigma(layerID);
float sigma2 = (float) ss.getSigma(layerID + 1);
// not sure if this is the correct way to handle the change in scale
float ss0 = (float) (Math.pow(sigma0, scalePower) / scale0);
float ss1 = (float) (Math.pow(sigma1, scalePower) / scale1);
float ss2 = (float) (Math.pow(sigma2, scalePower) / scale2);
for (int canIdx = 0; canIdx < candidates.size(); canIdx++) {
Point2D_I16 c = candidates.get(canIdx);
float val = ss1 * inten1.get(c.x, c.y);
// find pixel location in each image's local coordinate
int x0 = (int) (c.x * scale1 / scale0);
int y0 = (int) (c.y * scale1 / scale0);
int x2 = (int) (c.x * scale1 / scale2);
int y2 = (int) (c.y * scale1 / scale2);
if (checkMax(inten0, val / ss0, x0, y0) && checkMax(inten2, val / ss2, x2, y2)) {
// put features into the scale of the upper image
foundPoints.add(new ScalePoint(c.x * scale1, c.y * scale1, sigma1));
}
}
}
use of boofcv.struct.border.ImageBorder_F32 in project BoofCV by lessthanoptimal.
the class ImplEdgeNonMaxSuppressionCrude method border4.
/**
* Just processes the image border.
*/
public static void border4(GrayF32 _intensity, GrayF32 derivX, GrayF32 derivY, GrayF32 output) {
int w = _intensity.width;
int h = _intensity.height - 1;
ImageBorder_F32 intensity = FactoryImageBorderAlgs.value(_intensity, 0);
// CONCURRENT_BELOW BoofConcurrency.loopFor(0,w,x->{
for (int x = 0; x < w; x++) {
int dx, dy;
if (derivX.get(x, 0) > 0)
dx = 1;
else
dx = -1;
if (derivY.get(x, 0) > 0)
dy = 1;
else
dy = -1;
float left = intensity.get(x - dx, -dy);
float middle = intensity.get(x, 0);
float right = intensity.get(x + dx, dy);
if (left > middle || right > middle) {
output.set(x, 0, 0);
} else {
output.set(x, 0, middle);
}
}
// CONCURRENT_BELOW BoofConcurrency.loopFor(0,w,x->{
for (int x = 0; x < w; x++) {
int dx, dy;
if (derivX.get(x, h) > 0)
dx = 1;
else
dx = -1;
if (derivY.get(x, h) > 0)
dy = 1;
else
dy = -1;
float left = intensity.get(x - dx, h - dy);
float middle = intensity.get(x, h);
float right = intensity.get(x + dx, h + dy);
if (left > middle || right > middle) {
output.set(x, h, 0);
} else {
output.set(x, h, middle);
}
}
// CONCURRENT_BELOW BoofConcurrency.loopFor(1,h,y->{
for (int y = 1; y < h; y++) {
int dx, dy;
if (derivX.get(0, y) > 0)
dx = 1;
else
dx = -1;
if (derivY.get(0, y) > 0)
dy = 1;
else
dy = -1;
float left = intensity.get(-dx, y - dy);
float middle = intensity.get(0, y);
float right = intensity.get(dx, y + dy);
if (left > middle || right > middle) {
output.set(0, y, 0);
} else {
output.set(0, y, middle);
}
}
// CONCURRENT_ABOVE });
// right border
int ww = w - 1;
// CONCURRENT_BELOW BoofConcurrency.loopFor(1,h,y->{
for (int y = 1; y < h; y++) {
int dx, dy;
if (derivX.get(ww, y) > 0)
dx = 1;
else
dx = -1;
if (derivY.get(ww, y) > 0)
dy = 1;
else
dy = -1;
float left = intensity.get(ww - dx, y - dy);
float middle = intensity.get(ww, y);
float right = intensity.get(ww + dx, y + dy);
if (left > middle || right > middle) {
output.set(ww, y, 0);
} else {
output.set(ww, y, middle);
}
}
// CONCURRENT_ABOVE });
}
Aggregations