Search in sources :

Example 26 with ImageBorder_S32

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

the class ImplBinaryBorderOps method edge4.

public static GrayU8 edge4(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)) == 3)
            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, h - 1)) == 3)
            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(0, y + 1)) == 3)
            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, y - 1) + in.get(w, y + 1)) == 3)
            output.set(w, y, 0);
        else
            output.set(w, y, input.get(w, y));
    }
    return output;
}
Also used : ImageBorder_S32(boofcv.core.image.border.ImageBorder_S32)

Example 27 with ImageBorder_S32

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

the class ImplBinaryBorderOps method removePointNoise.

public static void removePointNoise(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
        int total = in.get(x - 1, 0) + in.get(x + 1, 0) + in.get(x - 1, 1) + in.get(x, 1) + in.get(x + 1, 1);
        if (total < 2)
            output.set(x, 0, 0);
        else
            output.set(x, 0, input.get(x, 0));
        // check bottom edge
        total = 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);
        if (total < 2)
            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
        int total = in.get(1, y) + in.get(0, y - 1) + in.get(1, y - 1) + in.get(0, y + 1) + in.get(1, y + 1);
        if (total < 2)
            output.set(0, y, 0);
        else
            output.set(0, y, input.get(0, y));
        // check right edge
        total = 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);
        if (total < 2)
            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 28 with ImageBorder_S32

use of boofcv.core.image.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.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, h - 1)) == 4)
            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(0, y + 1)) == 4)
            output.set(0, y, 1);
        else
            output.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.set(w, y, 1);
        else
            output.set(w, y, 0);
    }
}
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