Search in sources :

Example 6 with ImageBorder_F32

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

the class TestHessianFromGradient method hessianThree_F32.

@Test
public void hessianThree_F32() throws NoSuchMethodException {
    CompareHessianToConvolution validator = new CompareHessianToConvolution();
    validator.setTarget(HessianFromGradient.class.getMethod("hessianThree", GrayF32.class, GrayF32.class, GrayF32.class, GrayF32.class, GrayF32.class, ImageBorder_F32.class));
    validator.setKernel(0, GradientThree.kernelDeriv_F32, true);
    validator.setKernel(1, GradientThree.kernelDeriv_F32, false);
    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 7 with ImageBorder_F32

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

the class TestHessianFromGradient method hessianPrewitt_F32.

@Test
public void hessianPrewitt_F32() throws NoSuchMethodException {
    CompareHessianToConvolution validator = new CompareHessianToConvolution();
    validator.setTarget(HessianFromGradient.class.getMethod("hessianPrewitt", GrayF32.class, GrayF32.class, GrayF32.class, GrayF32.class, GrayF32.class, ImageBorder_F32.class));
    validator.setKernel(0, GradientPrewitt.kernelDerivX_F32);
    validator.setKernel(1, GradientPrewitt.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 8 with ImageBorder_F32

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

the class TestHessianThree method compareToConvolve_F32.

@Test
public void compareToConvolve_F32() throws NoSuchMethodException {
    CompareDerivativeToConvolution validator = new CompareDerivativeToConvolution();
    validator.setTarget(HessianThree.class.getMethod("process", GrayF32.class, GrayF32.class, GrayF32.class, GrayF32.class, ImageBorder_F32.class));
    validator.setKernel(0, HessianThree.kernelXXYY_F32, true);
    validator.setKernel(1, HessianThree.kernelXXYY_F32, false);
    validator.setKernel(2, HessianThree.kernelCross_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 9 with ImageBorder_F32

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

the class TestGradientSobel method compareToConvolve_F32.

@Test
public void compareToConvolve_F32() throws NoSuchMethodException {
    CompareDerivativeToConvolution validator = new CompareDerivativeToConvolution();
    validator.setTarget(GradientSobel.class.getMethod("process", GrayF32.class, GrayF32.class, GrayF32.class, ImageBorder_F32.class));
    validator.setKernel(0, GradientSobel.kernelDerivX_F32);
    validator.setKernel(1, GradientSobel.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);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) ImageBorder_F32(boofcv.core.image.border.ImageBorder_F32) Test(org.junit.Test)

Example 10 with ImageBorder_F32

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

the class ImplEdgeNonMaxSuppression method border8.

/**
 * Just processes the image border.
 */
public static void border8(GrayF32 _intensity, GrayS8 direction, GrayF32 output) {
    int w = _intensity.width;
    int h = _intensity.height - 1;
    ImageBorder_F32 intensity = (ImageBorder_F32) FactoryImageBorderAlgs.value(_intensity, 0);
    // top border
    for (int x = 0; x < w; x++) {
        int dir = direction.get(x, 0);
        int dx, dy;
        if (dir == 0 || dir == 4) {
            dx = 1;
            dy = 0;
        } else if (dir == 1 || dir == -3) {
            dx = 1;
            dy = 1;
        } else if (dir == 2 || dir == -2) {
            dx = 0;
            dy = 1;
        } else {
            dx = 1;
            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);
        }
    }
    // bottom border
    for (int x = 0; x < w; x++) {
        int dir = direction.get(x, h);
        int dx, dy;
        if (dir == 0 || dir == 4) {
            dx = 1;
            dy = 0;
        } else if (dir == 1 || dir == -3) {
            dx = 1;
            dy = 1;
        } else if (dir == 2 || dir == -2) {
            dx = 0;
            dy = 1;
        } else {
            dx = 1;
            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);
        }
    }
    // left border
    for (int y = 1; y < h; y++) {
        int dir = direction.get(0, y);
        int dx, dy;
        if (dir == 0 || dir == 4) {
            dx = 1;
            dy = 0;
        } else if (dir == 1 || dir == -3) {
            dx = 1;
            dy = 1;
        } else if (dir == 2 || dir == -2) {
            dx = 0;
            dy = 1;
        } else {
            dx = 1;
            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);
        }
    }
    // right border
    w = w - 1;
    for (int y = 1; y < h; y++) {
        int dir = direction.get(w, y);
        int dx, dy;
        if (dir == 0 || dir == 4) {
            dx = 1;
            dy = 0;
        } else if (dir == 1 || dir == -3) {
            dx = 1;
            dy = 1;
        } else if (dir == 2 || dir == -2) {
            dx = 0;
            dy = 1;
        } else {
            dx = 1;
            dy = -1;
        }
        float left = intensity.get(w - dx, y - dy);
        float middle = intensity.get(w, y);
        float right = intensity.get(w + dx, y + dy);
        if (left > middle || right > middle) {
            output.set(w, y, 0);
        } else {
            output.set(w, y, middle);
        }
    }
}
Also used : ImageBorder_F32(boofcv.core.image.border.ImageBorder_F32)

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