Search in sources :

Example 71 with GrayF32

use of boofcv.struct.image.GrayF32 in project BoofCV by lessthanoptimal.

the class TestDerivativeIntegralImage method derivYY.

@Test
public void derivYY() {
    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);
    for (int i = 1; i <= 5; i += 2) {
        int size = i * 3;
        Kernel2D_F32 kernel = createDerivXX(size);
        kernel = KernelMath.transpose(kernel);
        ConvolveImageNoBorder.convolve(kernel, orig, expected);
        DerivativeIntegralImage.derivYY(integral, found, size);
        int r = size / 2;
        GrayF32 a = expected.subimage(r + 1, r + 1, expected.width - r, expected.height - r, null);
        GrayF32 b = found.subimage(r + 1, r + 1, found.width - r, found.height - r, null);
        BoofTesting.assertEquals(a, b, 1e-2);
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32) Kernel2D_F32(boofcv.struct.convolve.Kernel2D_F32) Test(org.junit.Test)

Example 72 with GrayF32

use of boofcv.struct.image.GrayF32 in project BoofCV by lessthanoptimal.

the class TestPyramidDiscreteSampleBlur method _update.

public void _update(GrayF32 input) {
    Kernel1D_F32 kernel = FactoryKernelGaussian.gaussian(Kernel1D_F32.class, -1, 3);
    GrayF32 convImg = new GrayF32(width, height);
    GrayF32 convImg2 = new GrayF32(width / 2, height / 2);
    GrayF32 storage = new GrayF32(width, height);
    ConvolveImageNormalized.horizontal(kernel, input, storage);
    ConvolveImageNormalized.vertical(kernel, storage, convImg);
    PyramidDiscreteSampleBlur<GrayF32> alg = new PyramidDiscreteSampleBlur<>(kernel, 3, ImageType.single(GrayF32.class), true, new int[] { 1, 2, 4 });
    alg.process(input);
    // top layer should be the same as the input layer
    BoofTesting.assertEquals(input, alg.getLayer(0), 1e-4f);
    // second layer should have the same values as the convolved image
    for (int i = 0; i < height; i += 2) {
        for (int j = 0; j < width; j += 2) {
            float a = convImg.get(j, i);
            float b = alg.getLayer(1).get(j / 2, i / 2);
            assertEquals(a, b, 1e-4);
        }
    }
    storage.reshape(width / 2, height / 2);
    ConvolveImageNormalized.horizontal(kernel, alg.getLayer(1), storage);
    ConvolveImageNormalized.vertical(kernel, storage, convImg2);
    // second layer should have the same values as the second convolved image
    for (int i = 0; i < height / 2; i += 2) {
        for (int j = 0; j < width / 2; j += 2) {
            float a = convImg2.get(j, i);
            float b = alg.getLayer(2).get(j / 2, i / 2);
            assertEquals(j + " " + j, a, b, 1e-4);
        }
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32) Kernel1D_F32(boofcv.struct.convolve.Kernel1D_F32)

Example 73 with GrayF32

use of boofcv.struct.image.GrayF32 in project BoofCV by lessthanoptimal.

the class TestPyramidDiscreteSampleBlur method checkSigmas.

/**
 * Makes sure the amount of Gaussian blur in each level is correctly computed
 */
@Test
public void checkSigmas() {
    Kernel1D_F32 kernel = FactoryKernelGaussian.gaussian(Kernel1D_F32.class, -1, 3);
    PyramidDiscreteSampleBlur<GrayF32> alg = new PyramidDiscreteSampleBlur<>(kernel, 3, ImageType.single(GrayF32.class), true, new int[] { 1, 2, 4 });
    assertEquals(0, alg.getSigma(0), 1e-8);
    assertEquals(3, alg.getSigma(1), 1e-8);
    assertEquals(6.7082, alg.getSigma(2), 1e-3);
    alg = new PyramidDiscreteSampleBlur<>(kernel, 3, ImageType.single(GrayF32.class), true, new int[] { 2, 4, 8 });
    assertEquals(0, alg.getSigma(0), 1e-8);
    assertEquals(6, alg.getSigma(1), 1e-8);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) Kernel1D_F32(boofcv.struct.convolve.Kernel1D_F32) Test(org.junit.Test)

Example 74 with GrayF32

use of boofcv.struct.image.GrayF32 in project BoofCV by lessthanoptimal.

the class TestPyramidFloatGaussianScale method update.

/**
 * Compares update to a convolution and sub-sampling of upper layers.
 */
@Test
public void update() {
    GrayF32 img = new GrayF32(width, height);
    BoofTesting.checkSubImage(this, "_update", true, img);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) Test(org.junit.Test)

Example 75 with GrayF32

use of boofcv.struct.image.GrayF32 in project BoofCV by lessthanoptimal.

the class TestPyramidFloatScale method _update.

public void _update(GrayF32 input) {
    InterpolatePixelS<GrayF32> interp = FactoryInterpolation.bilinearPixelS(input, BorderType.EXTENDED);
    PyramidFloatScale<GrayF32> alg = new PyramidFloatScale<>(interp, new double[] { 3, 5 }, imageType);
    alg.process(input);
    // test the first layer
    GrayF32 expected = new GrayF32((int) Math.ceil(width / 3.0), (int) Math.ceil(height / 3.0));
    new FDistort(input, expected).scale().apply();
    GrayF32 found = alg.getLayer(0);
    BoofTesting.assertEquals(expected, found, 1e-4);
    // test the second layer
    GrayF32 next = new GrayF32((int) Math.ceil(width / 5.0), (int) Math.ceil(height / 5.0));
    new FDistort(expected, next).scale().apply();
    found = alg.getLayer(1);
    BoofTesting.assertEquals(next, found, 1e-4);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) FDistort(boofcv.abst.distort.FDistort)

Aggregations

GrayF32 (boofcv.struct.image.GrayF32)530 Test (org.junit.Test)291 BufferedImage (java.awt.image.BufferedImage)81 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)76 GrayU8 (boofcv.struct.image.GrayU8)49 Planar (boofcv.struct.image.Planar)34 ArrayList (java.util.ArrayList)28 ImageBorder_F32 (boofcv.core.image.border.ImageBorder_F32)20 ImageGray (boofcv.struct.image.ImageGray)20 File (java.io.File)20 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)19 Se3_F64 (georegression.struct.se.Se3_F64)18 TupleDesc_F64 (boofcv.struct.feature.TupleDesc_F64)17 GrayS8 (boofcv.struct.image.GrayS8)16 ListDisplayPanel (boofcv.gui.ListDisplayPanel)14 PathLabel (boofcv.io.PathLabel)14 Kernel2D_F32 (boofcv.struct.convolve.Kernel2D_F32)13 GrayS16 (boofcv.struct.image.GrayS16)13 GrayS32 (boofcv.struct.image.GrayS32)13 Point2D_F64 (georegression.struct.point.Point2D_F64)13