Search in sources :

Example 21 with ImageBorder_S32

use of boofcv.struct.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.unsafe_set(x, 0, 0);
        else
            output.unsafe_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.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
        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.unsafe_set(0, y, 0);
        else
            output.unsafe_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.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 22 with ImageBorder_S32

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

the class ImplBinaryBorderOps method dilate4.

public static void dilate4(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)) > 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, 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(0, y + 1)) > 0)
            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)) > 0)
            output.unsafe_set(w, y, 1);
        else
            output.unsafe_set(w, y, 0);
    }
}
Also used : ImageBorder_S32(boofcv.struct.border.ImageBorder_S32)

Example 23 with ImageBorder_S32

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

the class ImplBilinearPixel_S16 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.struct.border.ImageBorder_S32)

Example 24 with ImageBorder_S32

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

the class ImplBilinearPixel_U16 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.struct.border.ImageBorder_S32)

Example 25 with ImageBorder_S32

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

the class ImplPolynomialPixel_I method get_border.

public float get_border(float x, float y) {
    int xt = (int) Math.floor(x);
    int yt = (int) Math.floor(y);
    int x0 = xt - M / 2 + offM;
    int y0 = yt - M / 2 + offM;
    ImageBorder_S32 border = (ImageBorder_S32) this.border;
    interp1D.setInput(horiz, horiz.length);
    for (int i = 0; i < M; i++) {
        for (int j = 0; j < M; j++) {
            horiz[j] = border.get(j + x0, i + y0);
        }
        vert[i] = interp1D.process(x - x0, 0, M - 1);
    }
    interp1D.setInput(vert, vert.length);
    float ret = interp1D.process(y - y0, 0, M - 1);
    // because it is fitting polynomials it can go above or below max or min values.
    if (ret > max) {
        ret = max;
    } else if (ret < min) {
        ret = min;
    }
    return ret;
}
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