Search in sources :

Example 1 with ImageBorder_F32

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

the class ImplPolynomialPixel_F32 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_F32 border = (ImageBorder_F32) 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_F32(boofcv.struct.border.ImageBorder_F32)

Example 2 with ImageBorder_F32

use of boofcv.struct.border.ImageBorder_F32 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 = GImageDerivativeOps.borderDerivative_I32();
        border.setImage(input);
        ConvolveJustBorder_General_SB.convolve(EnhanceImageOps.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 = GImageDerivativeOps.borderDerivative_F32();
        border.setImage((GrayF32) input);
        ConvolveJustBorder_General_SB.convolve(EnhanceImageOps.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.struct.border.ImageBorder_F32) ImageBorder_S32(boofcv.struct.border.ImageBorder_S32)

Example 3 with ImageBorder_F32

use of boofcv.struct.border.ImageBorder_F32 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 = GImageDerivativeOps.borderDerivative_I32();
        border.setImage(input);
        ConvolveJustBorder_General_SB.convolve(EnhanceImageOps.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 = GImageDerivativeOps.borderDerivative_F32();
        border.setImage((GrayF32) input);
        ConvolveJustBorder_General_SB.convolve(EnhanceImageOps.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.struct.border.ImageBorder_F32) ImageBorder_S32(boofcv.struct.border.ImageBorder_S32)

Example 4 with ImageBorder_F32

use of boofcv.struct.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.struct.border.ImageBorder_F32) Test(org.junit.jupiter.api.Test)

Example 5 with ImageBorder_F32

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

the class TestGradientTwo0 method compareToConvolve_F32.

@Test
public void compareToConvolve_F32() throws NoSuchMethodException {
    CompareDerivativeToConvolution validator = new CompareDerivativeToConvolution();
    validator.setTarget(GradientTwo0.class.getMethod("process", GrayF32.class, GrayF32.class, GrayF32.class, ImageBorder_F32.class));
    validator.setKernel(0, GradientTwo0.kernelDeriv_F32, true);
    validator.setKernel(1, GradientTwo0.kernelDeriv_F32, false);
    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.struct.border.ImageBorder_F32) Test(org.junit.jupiter.api.Test)

Aggregations

ImageBorder_F32 (boofcv.struct.border.ImageBorder_F32)34 GrayF32 (boofcv.struct.image.GrayF32)25 Test (org.junit.jupiter.api.Test)17 Kernel2D_F32 (boofcv.struct.convolve.Kernel2D_F32)7 ImageBorder_S32 (boofcv.struct.border.ImageBorder_S32)2 GrayS16 (boofcv.struct.image.GrayS16)2 ImageGray (boofcv.struct.image.ImageGray)2 ScalePoint (boofcv.struct.feature.ScalePoint)1 Point2D_I16 (georegression.struct.point.Point2D_I16)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Random (java.util.Random)1