Search in sources :

Example 1 with ImageBorder_F32

use of boofcv.core.image.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 = 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 2 with ImageBorder_F32

use of boofcv.core.image.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 = 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 3 with ImageBorder_F32

use of boofcv.core.image.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.core.image.border.ImageBorder_F32)

Example 4 with ImageBorder_F32

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

the class TestDerivativeIntegralImage method kernelDerivXX.

@Test
public void kernelDerivXX() {
    GrayF32 orig = new GrayF32(width, height);
    GrayF32 integral = new GrayF32(width, height);
    ImageMiscOps.fillUniform(orig, rand, 0, 20);
    GrayF32 expected = new GrayF32(width, height);
    GrayF32 found = new GrayF32(width, height);
    IntegralImageOps.transform(orig, integral);
    ImageBorder_F32 border = (ImageBorder_F32) FactoryImageBorderAlgs.value(orig, 0);
    for (int i = 1; i <= 5; i += 2) {
        int size = i * 3;
        IntegralKernel kernelI = DerivativeIntegralImage.kernelDerivXX(size, null);
        Kernel2D_F32 kernel = createDerivXX(size);
        ConvolveImage.convolve(kernel, orig, expected, border);
        IntegralImageOps.convolve(integral, kernelI, found);
        BoofTesting.assertEquals(expected, found, 1e-2);
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32) Kernel2D_F32(boofcv.struct.convolve.Kernel2D_F32) ImageBorder_F32(boofcv.core.image.border.ImageBorder_F32) Test(org.junit.Test)

Example 5 with ImageBorder_F32

use of boofcv.core.image.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.core.image.border.ImageBorder_F32) Test(org.junit.Test)

Aggregations

ImageBorder_F32 (boofcv.core.image.border.ImageBorder_F32)29 GrayF32 (boofcv.struct.image.GrayF32)20 Test (org.junit.Test)16 Kernel2D_F32 (boofcv.struct.convolve.Kernel2D_F32)7 ImageBorder_S32 (boofcv.core.image.border.ImageBorder_S32)2 ScalePoint (boofcv.struct.feature.ScalePoint)2 GrayS16 (boofcv.struct.image.GrayS16)2 ImageGray (boofcv.struct.image.ImageGray)2 Point2D_I16 (georegression.struct.point.Point2D_I16)2 QueueCorner (boofcv.struct.QueueCorner)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Random (java.util.Random)1