Search in sources :

Example 1 with ImageBorder_S32

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

the class ImplBinaryBorderOps method edge8.

public static void edge8(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.set(x, 0, 0);
        else
            output.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.set(x, h, 0);
        else
            output.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.set(0, y, 0);
        else
            output.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.set(w, y, 0);
        else
            output.set(w, y, input.get(w, y));
    }
}
Also used : ImageBorder_S32(boofcv.core.image.border.ImageBorder_S32)

Example 2 with ImageBorder_S32

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

the class ImplBinaryBorderOps method erode8.

public static void erode8(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, 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)) == 6)
            output.set(x, 0, 1);
        else
            output.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)) == 6)
            output.set(x, h, 1);
        else
            output.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)) == 6)
            output.set(0, y, 1);
        else
            output.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)) == 6)
            output.set(w, y, 1);
        else
            output.set(w, y, 0);
    }
}
Also used : ImageBorder_S32(boofcv.core.image.border.ImageBorder_S32)

Example 3 with ImageBorder_S32

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

the class TestImplEnhanceFilter method sharpenBorder4.

public void sharpenBorder4(ImageGray input, ImageGray output) {
    ImageGray expected;
    GImageMiscOps.fillUniform(input, rand, 0, 10);
    if (input.getDataType().isInteger()) {
        BoofTesting.callStaticMethod(ImplEnhanceFilter.class, "sharpenBorder4", input, output, 0, 255);
        expected = new GrayS16(input.width, input.height);
        ImageBorder_S32 border = BoofDefaults.borderDerivative_I32();
        border.setImage(input);
        ConvolveJustBorder_General_SB.convolve(ImplEnhanceFilter.kernelEnhance4_I32, border, (GrayS16) expected);
        GPixelMath.boundImage(expected, 0, 255);
    } else {
        BoofTesting.callStaticMethod(ImplEnhanceFilter.class, "sharpenBorder4", input, output, 0f, 255f);
        expected = new GrayF32(input.width, input.height);
        ImageBorder_F32 border = BoofDefaults.borderDerivative_F32();
        border.setImage((GrayF32) input);
        ConvolveJustBorder_General_SB.convolve(ImplEnhanceFilter.kernelEnhance4_F32, border, (GrayF32) expected);
        GPixelMath.boundImage(expected, 0, 255);
    }
    BoofTesting.assertEquals(expected, output, 1e-5);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) GrayS16(boofcv.struct.image.GrayS16) ImageGray(boofcv.struct.image.ImageGray) ImageBorder_F32(boofcv.core.image.border.ImageBorder_F32) ImageBorder_S32(boofcv.core.image.border.ImageBorder_S32)

Example 4 with ImageBorder_S32

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

the class TestImplEnhanceFilter method sharpenBorder8.

public void sharpenBorder8(ImageGray input, ImageGray output) {
    ImageGray expected;
    GImageMiscOps.fillUniform(input, rand, 0, 10);
    if (input.getDataType().isInteger()) {
        BoofTesting.callStaticMethod(ImplEnhanceFilter.class, "sharpenBorder8", input, output, 0, 255);
        expected = new GrayS16(input.width, input.height);
        ImageBorder_S32 border = BoofDefaults.borderDerivative_I32();
        border.setImage(input);
        ConvolveJustBorder_General_SB.convolve(ImplEnhanceFilter.kernelEnhance8_I32, border, (GrayS16) expected);
        GPixelMath.boundImage(expected, 0, 255);
    } else {
        BoofTesting.callStaticMethod(ImplEnhanceFilter.class, "sharpenBorder8", input, output, 0f, 255f);
        expected = new GrayF32(input.width, input.height);
        ImageBorder_F32 border = BoofDefaults.borderDerivative_F32();
        border.setImage((GrayF32) input);
        ConvolveJustBorder_General_SB.convolve(ImplEnhanceFilter.kernelEnhance8_F32, border, (GrayF32) expected);
        GPixelMath.boundImage(expected, 0, 255);
    }
    BoofTesting.assertEquals(expected, output, 1e-5);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) GrayS16(boofcv.struct.image.GrayS16) ImageGray(boofcv.struct.image.ImageGray) ImageBorder_F32(boofcv.core.image.border.ImageBorder_F32) ImageBorder_S32(boofcv.core.image.border.ImageBorder_S32)

Example 5 with ImageBorder_S32

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

the class ImplBilinearPixel_S32 method get_border.

public float get_border(float x, float y) {
    float xf = (float) Math.floor(x);
    float yf = (float) Math.floor(y);
    int xt = (int) xf;
    int yt = (int) yf;
    float ax = x - xf;
    float ay = y - yf;
    ImageBorder_S32 border = (ImageBorder_S32) this.border;
    // (x,y)
    float val = (1.0f - ax) * (1.0f - ay) * border.get(xt, yt);
    // (x+1,y)
    val += ax * (1.0f - ay) * border.get(xt + 1, yt);
    // (x+1,y)
    ;
    // (x+1,y+1)
    val += ax * ay * border.get(xt + 1, yt + 1);
    // (x+1,y+1)
    ;
    // (x,y+1)
    val += (1.0f - ax) * ay * border.get(xt, yt + 1);
    // (x,y+1)
    ;
    return val;
}
Also used : ImageBorder_S32(boofcv.core.image.border.ImageBorder_S32)

Aggregations

ImageBorder_S32 (boofcv.core.image.border.ImageBorder_S32)28 GrayS16 (boofcv.struct.image.GrayS16)15 Test (org.junit.Test)13 GrayU8 (boofcv.struct.image.GrayU8)8 ImageGray (boofcv.struct.image.ImageGray)4 IntegralKernel (boofcv.alg.transform.ii.IntegralKernel)2 FactoryGImageGray (boofcv.core.image.FactoryGImageGray)2 GImageGray (boofcv.core.image.GImageGray)2 ImageBorder_F32 (boofcv.core.image.border.ImageBorder_F32)2 ImageRectangle (boofcv.struct.ImageRectangle)2 Kernel2D_S32 (boofcv.struct.convolve.Kernel2D_S32)2 GrayF32 (boofcv.struct.image.GrayF32)2 GrayS32 (boofcv.struct.image.GrayS32)2