use of boofcv.struct.image.GrayF32 in project BoofCV by lessthanoptimal.
the class KernelMath method convertToImage.
public static GrayF32 convertToImage(Kernel2D_F32 kernel) {
int w = kernel.getWidth();
GrayF32 ret = new GrayF32(w, w);
for (int i = 0; i < w; i++) {
for (int j = 0; j < w; j++) {
ret.set(j, i, kernel.get(j, i));
}
}
return ret;
}
use of boofcv.struct.image.GrayF32 in project BoofCV by lessthanoptimal.
the class ImageLocalNormalization method computeOutput.
private void computeOutput(GrayF32 input, float delta, GrayF32 output, GrayF32 adjusted) {
GrayF32 localMean = (GrayF32) this.localMean;
GrayF32 localPow2 = (GrayF32) this.localPow2;
for (int y = 0; y < input.height; y++) {
int indexIn = y * input.width;
int indexEnd = indexIn + input.width;
int indexOut = output.startIndex + y * output.stride;
while (indexIn < indexEnd) {
float ave = localMean.data[indexIn];
float std = (float) Math.sqrt(localPow2.data[indexIn] - ave * ave + delta);
output.data[indexOut++] = (adjusted.data[indexIn] - ave) / std;
indexIn++;
}
}
}
use of boofcv.struct.image.GrayF32 in project BoofCV by lessthanoptimal.
the class TestPyramidOps method hessian.
@Test
public void hessian() {
ImageHessian<GrayF32> gradient = FactoryDerivative.hessianThree(GrayF32.class);
GrayF32[] derivX = new GrayF32[5];
GrayF32[] derivY = new GrayF32[5];
GrayF32[] derivXX = new GrayF32[5];
GrayF32[] derivYY = new GrayF32[5];
GrayF32[] derivXY = new GrayF32[5];
for (int i = 0; i < 5; i++) {
derivX[i] = new GrayF32(20, 30 - i);
derivY[i] = new GrayF32(20, 30 - i);
derivXX[i] = new GrayF32(20, 30 - i);
derivYY[i] = new GrayF32(20, 30 - i);
derivXY[i] = new GrayF32(20, 30 - i);
GImageMiscOps.fillUniform(derivX[i], rand, 0, 100);
GImageMiscOps.fillUniform(derivY[i], rand, 0, 100);
}
PyramidOps.hessian(derivX, derivY, gradient, derivXX, derivYY, derivXY);
for (int i = 0; i < derivX.length; i++) {
GrayF32 dx = derivX[i];
GrayF32 dy = derivY[i];
GrayF32 foundXX = new GrayF32(dx.width, dy.height);
GrayF32 foundYY = new GrayF32(dx.width, dy.height);
GrayF32 foundXY = new GrayF32(dx.width, dy.height);
gradient.process(dx, dy, foundXX, foundYY, foundXY);
BoofTesting.assertEquals(foundXX, derivXX[i], 1e-4);
BoofTesting.assertEquals(foundYY, derivYY[i], 1e-4);
BoofTesting.assertEquals(foundXY, derivXY[i], 1e-4);
}
}
use of boofcv.struct.image.GrayF32 in project BoofCV by lessthanoptimal.
the class TestUtilWavelet method checkShape_positive.
@Test
public void checkShape_positive() {
GrayF32 orig = new GrayF32(10, 20);
GrayF32 transformed = new GrayF32(10, 20);
UtilWavelet.checkShape(orig, transformed);
orig = new GrayF32(9, 19);
UtilWavelet.checkShape(orig, transformed);
}
use of boofcv.struct.image.GrayF32 in project BoofCV by lessthanoptimal.
the class TestDerivativeIntegralImage method kernelDerivXX.
@Test
public void kernelDerivXX() {
GrayF32 orig = new GrayF32(width, height);
GrayF32 integral = new GrayF32(width, height);
ImageMiscOps.fillUniform(orig, rand, 0, 20);
GrayF32 expected = new GrayF32(width, height);
GrayF32 found = new GrayF32(width, height);
IntegralImageOps.transform(orig, integral);
ImageBorder_F32 border = (ImageBorder_F32) FactoryImageBorderAlgs.value(orig, 0);
for (int i = 1; i <= 5; i += 2) {
int size = i * 3;
IntegralKernel kernelI = DerivativeIntegralImage.kernelDerivXX(size, null);
Kernel2D_F32 kernel = createDerivXX(size);
ConvolveImage.convolve(kernel, orig, expected, border);
IntegralImageOps.convolve(integral, kernelI, found);
BoofTesting.assertEquals(expected, found, 1e-2);
}
}
Aggregations