Search in sources :

Example 26 with ImageBorder_F32

use of boofcv.core.image.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);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) ImageBorder_F32(boofcv.core.image.border.ImageBorder_F32) Test(org.junit.Test)

Example 27 with ImageBorder_F32

use of boofcv.core.image.border.ImageBorder_F32 in project BoofCV by lessthanoptimal.

the class TestHessianFromGradient method hessianSobel_F32.

@Test
public 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);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) ImageBorder_F32(boofcv.core.image.border.ImageBorder_F32) Test(org.junit.Test)

Example 28 with ImageBorder_F32

use of boofcv.core.image.border.ImageBorder_F32 in project BoofCV by lessthanoptimal.

the class TestHessianSobel method compareToConvolve_F32.

@Test
public void compareToConvolve_F32() throws NoSuchMethodException {
    CompareDerivativeToConvolution validator = new CompareDerivativeToConvolution();
    validator.setTarget(HessianSobel.class.getMethod("process", GrayF32.class, GrayF32.class, GrayF32.class, GrayF32.class, ImageBorder_F32.class));
    validator.setKernel(0, HessianSobel.kernelXX_F32);
    validator.setKernel(1, HessianSobel.kernelYY_F32);
    validator.setKernel(2, HessianSobel.kernelXY_F32);
    GrayF32 input = new GrayF32(width, height);
    ImageMiscOps.fillUniform(input, rand, 0, 10);
    GrayF32 derivXX = new GrayF32(width, height);
    GrayF32 derivYY = new GrayF32(width, height);
    GrayF32 derivXY = new GrayF32(width, height);
    validator.compare(input, derivXX, derivYY, derivXY);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) ImageBorder_F32(boofcv.core.image.border.ImageBorder_F32) Test(org.junit.Test)

Example 29 with ImageBorder_F32

use of boofcv.core.image.border.ImageBorder_F32 in project BoofCV by lessthanoptimal.

the class TestImplEdgeNonMaxSuppressionCrude method border.

public static <D extends ImageGray<D>> void border(Method m, GrayF32 input, D derivX, D derivY, GrayF32 output) {
    Random rand = new Random(123);
    GImageMiscOps.fillUniform(input, rand, 0, 30);
    GImageMiscOps.fillUniform(derivX, rand, -30, 30);
    GImageMiscOps.fillUniform(derivY, rand, -30, 30);
    try {
        m.invoke(null, input, derivX, derivY, output);
        ImageBorder_F32 intensity = (ImageBorder_F32) FactoryImageBorderAlgs.value(input, 0);
        for (int y = 0; y < input.height; y++) {
            if (y != 0 && y != input.height - 1)
                continue;
            for (int x = 0; x < input.width; x++) {
                if (x != 0 && x != input.width - 1)
                    continue;
                int dx = GeneralizedImageOps.get(derivX, x, y) > 0 ? 1 : -1;
                int dy = GeneralizedImageOps.get(derivY, x, y) > 0 ? 1 : -1;
                float left = intensity.get(x - dx, y - dy);
                float middle = intensity.get(x, y);
                float right = intensity.get(x + dx, y + dy);
                assertEquals((left < middle && right < middle), output.get(x, y) != 0);
            }
        }
        // uniform case should be NOT suppressed
        GImageMiscOps.fill(input, 2);
        m.invoke(null, input, derivX, derivY, output);
        for (int y = 0; y < input.height; y++) {
            if (y != 0 && y != input.height - 1)
                continue;
            for (int x = 0; x < input.width; x++) {
                if (x != 0 && x != input.width - 1)
                    continue;
                // the two adjacent pixels could be outside the image, depending on gradient direction
                if ((x == 0 && y == 0) || (x == input.width - 1 && y == 0))
                    continue;
                if ((x == input.width - 1 && y == input.height - 1) || (x == 0 && y == input.height - 1))
                    continue;
                assertTrue(output.get(x, y) == 2);
            }
        }
    } catch (IllegalAccessException | InvocationTargetException e) {
        throw new RuntimeException(e);
    }
}
Also used : Random(java.util.Random) ImageBorder_F32(boofcv.core.image.border.ImageBorder_F32) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

ImageBorder_F32 (boofcv.core.image.border.ImageBorder_F32)29 GrayF32 (boofcv.struct.image.GrayF32)20 Test (org.junit.Test)16 Kernel2D_F32 (boofcv.struct.convolve.Kernel2D_F32)7 ImageBorder_S32 (boofcv.core.image.border.ImageBorder_S32)2 ScalePoint (boofcv.struct.feature.ScalePoint)2 GrayS16 (boofcv.struct.image.GrayS16)2 ImageGray (boofcv.struct.image.ImageGray)2 Point2D_I16 (georegression.struct.point.Point2D_I16)2 QueueCorner (boofcv.struct.QueueCorner)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Random (java.util.Random)1