Search in sources :

Example 16 with ImageBorder_S32

use of boofcv.struct.border.ImageBorder_S32 in project BoofCV by lessthanoptimal.

the class TestHessianThreeDeterminant_Border method process_U8_S16.

public void process_U8_S16(GrayU8 img, GrayS16 deriv) {
    ImageBorder_S32<GrayU8> border = (ImageBorder_S32) FactoryImageBorder.single(BorderType.EXTENDED, GrayU8.class);
    HessianThreeDeterminant_Border.process(img, deriv, border);
    GrayS16 expected = hessianDetFromConv_U8_S16(img);
    BoofTesting.assertEqualsBorder(expected, deriv, 0, 2, 2);
}
Also used : GrayS16(boofcv.struct.image.GrayS16) GrayU8(boofcv.struct.image.GrayU8) ImageBorder_S32(boofcv.struct.border.ImageBorder_S32)

Example 17 with ImageBorder_S32

use of boofcv.struct.border.ImageBorder_S32 in project BoofCV by lessthanoptimal.

the class TestImplIntegralImageConvolve method convolveBorder.

public void convolveBorder(Method m) throws InvocationTargetException, IllegalAccessException {
    Kernel2D_S32 kernel = new Kernel2D_S32(3, new int[] { 1, 1, 1, 2, 2, 2, 1, 1, 1 });
    GrayU8 input = new GrayU8(width, height);
    GrayS32 expected = new GrayS32(width, height);
    GImageMiscOps.fillUniform(input, rand, 0, 10);
    ImageBorder_S32 border = FactoryImageBorderAlgs.value(input, 0);
    ConvolveImage.convolve(kernel, input, expected, border);
    Class[] paramType = m.getParameterTypes();
    Class inputType = paramType[0];
    Class outputType = paramType[2];
    ImageGray inputII = GeneralizedImageOps.createSingleBand(inputType, width, height);
    ImageGray integral = GeneralizedImageOps.createSingleBand(outputType, width, height);
    ImageGray expectedII = GeneralizedImageOps.createSingleBand(outputType, width, height);
    ImageGray found = GeneralizedImageOps.createSingleBand(outputType, width, height);
    GConvertImage.convert(input, inputII);
    GConvertImage.convert(expected, expectedII);
    GIntegralImageOps.transform(inputII, integral);
    IntegralKernel kernelII = new IntegralKernel(2);
    kernelII.blocks[0] = new ImageRectangle(-2, -2, 1, 1);
    kernelII.blocks[1] = new ImageRectangle(-2, -1, 1, 0);
    kernelII.scales = new int[] { 1, 1 };
    m.invoke(null, integral, kernelII, found, 4, 5);
    BoofTesting.assertEqualsBorder(expected, found, 1e-4f, 4, 5);
}
Also used : Kernel2D_S32(boofcv.struct.convolve.Kernel2D_S32) IntegralKernel(boofcv.alg.transform.ii.IntegralKernel) ImageRectangle(boofcv.struct.ImageRectangle) GrayU8(boofcv.struct.image.GrayU8) ImageGray(boofcv.struct.image.ImageGray) ImageBorder_S32(boofcv.struct.border.ImageBorder_S32) GrayS32(boofcv.struct.image.GrayS32)

Example 18 with ImageBorder_S32

use of boofcv.struct.border.ImageBorder_S32 in project BoofCV by lessthanoptimal.

the class ImplBinaryBorderOps method dilate8.

public static void dilate8(GrayU8 input, GrayU8 output) {
    ImageBorder_S32 in = ImageBorderValue.wrap(input, 0);
    final int h = input.height - 1;
    final int w = input.width - 1;
    for (int x = 0; x < input.width; x++) {
        // check top edge
        if ((in.get(x, 0) + in.get(x - 1, 0) + in.get(x + 1, 0) + in.get(x - 1, 1) + in.get(x, 1) + in.get(x + 1, 1)) > 0)
            output.unsafe_set(x, 0, 1);
        else
            output.unsafe_set(x, 0, 0);
        // check bottom edge
        if ((in.get(x, h) + in.get(x - 1, h) + in.get(x + 1, h) + in.get(x - 1, h - 1) + in.get(x, h - 1) + in.get(x + 1, h - 1)) > 0)
            output.unsafe_set(x, h, 1);
        else
            output.unsafe_set(x, h, 0);
    }
    for (int y = 0; y < input.height; y++) {
        // check left edge
        if ((in.get(0, y) + in.get(1, y) + in.get(0, y - 1) + in.get(1, y - 1) + in.get(0, y + 1) + in.get(1, y + 1)) > 0)
            output.unsafe_set(0, y, 1);
        else
            output.unsafe_set(0, y, 0);
        // check right edge
        if ((in.get(w - 1, y) + in.get(w, y) + in.get(w - 1, y - 1) + in.get(w, y - 1) + in.get(w - 1, y + 1) + in.get(w, y + 1)) > 0)
            output.unsafe_set(w, y, 1);
        else
            output.unsafe_set(w, y, 0);
    }
}
Also used : ImageBorder_S32(boofcv.struct.border.ImageBorder_S32)

Example 19 with ImageBorder_S32

use of boofcv.struct.border.ImageBorder_S32 in project BoofCV by lessthanoptimal.

the class ImplBinaryBorderOps method edge8_outside1.

private static void edge8_outside1(GrayU8 input, GrayU8 output) {
    ImageBorder_S32 in = ImageBorderValue.wrap(input, 1);
    final int h = input.height - 1;
    final int w = input.width - 1;
    for (int x = 0; x < input.width; x++) {
        // check top edge
        if ((in.get(x - 1, 0) + in.get(x + 1, 0) + in.get(x - 1, 1) + in.get(x, 1) + in.get(x + 1, 1)) == 5)
            output.unsafe_set(x, 0, 0);
        else
            output.unsafe_set(x, 0, input.get(x, 0));
        // check bottom edge
        if ((in.get(x - 1, h) + in.get(x + 1, h) + in.get(x - 1, h - 1) + in.get(x, h - 1) + in.get(x + 1, h - 1)) == 5)
            output.unsafe_set(x, h, 0);
        else
            output.unsafe_set(x, h, input.get(x, h));
    }
    for (int y = 0; y < input.height; y++) {
        // check left edge
        if ((in.get(1, y) + in.get(0, y - 1) + in.get(1, y - 1) + in.get(0, y + 1) + in.get(1, y + 1)) == 5)
            output.unsafe_set(0, y, 0);
        else
            output.unsafe_set(0, y, input.get(0, y));
        // check right edge
        if ((in.get(w - 1, y) + in.get(w - 1, y - 1) + in.get(w, y - 1) + in.get(w - 1, y + 1) + in.get(w, y + 1)) == 5)
            output.unsafe_set(w, y, 0);
        else
            output.unsafe_set(w, y, input.get(w, y));
    }
}
Also used : ImageBorder_S32(boofcv.struct.border.ImageBorder_S32)

Example 20 with ImageBorder_S32

use of boofcv.struct.border.ImageBorder_S32 in project BoofCV by lessthanoptimal.

the class ImplBinaryBorderOps method erode4.

public static void erode4(GrayU8 input, GrayU8 output) {
    ImageBorder_S32 in = ImageBorderValue.wrap(input, 0);
    final int h = input.height - 1;
    final int w = input.width - 1;
    for (int x = 0; x < input.width; x++) {
        // check top edge
        if ((in.get(x, 0) + in.get(x - 1, 0) + in.get(x + 1, 0) + in.get(x, 1)) == 4)
            output.unsafe_set(x, 0, 1);
        else
            output.unsafe_set(x, 0, 0);
        // check bottom edge
        if ((in.get(x, h) + in.get(x - 1, h) + in.get(x + 1, h) + in.get(x, h - 1)) == 4)
            output.unsafe_set(x, h, 1);
        else
            output.unsafe_set(x, h, 0);
    }
    for (int y = 0; y < input.height; y++) {
        // check left edge
        if ((in.get(0, y) + in.get(1, y) + in.get(0, y - 1) + in.get(0, y + 1)) == 4)
            output.unsafe_set(0, y, 1);
        else
            output.unsafe_set(0, y, 0);
        // check right edge
        if ((in.get(w, y) + in.get(w - 1, y) + in.get(w, y - 1) + in.get(w, y + 1)) == 4)
            output.unsafe_set(w, y, 1);
        else
            output.unsafe_set(w, y, 0);
    }
}
Also used : ImageBorder_S32(boofcv.struct.border.ImageBorder_S32)

Aggregations

ImageBorder_S32 (boofcv.struct.border.ImageBorder_S32)37 GrayS16 (boofcv.struct.image.GrayS16)23 GrayU8 (boofcv.struct.image.GrayU8)15 Test (org.junit.jupiter.api.Test)15 ImageGray (boofcv.struct.image.ImageGray)4 IntegralKernel (boofcv.alg.transform.ii.IntegralKernel)2 ImageRectangle (boofcv.struct.ImageRectangle)2 ImageBorder_F32 (boofcv.struct.border.ImageBorder_F32)2 Kernel2D_S32 (boofcv.struct.convolve.Kernel2D_S32)2 GrayF32 (boofcv.struct.image.GrayF32)2 GrayS32 (boofcv.struct.image.GrayS32)2