Search in sources :

Example 11 with ImageBorder

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

the class TestImplCensusTransformBorder method sample_compare5x5.

@Test
void sample_compare5x5() {
    Random rand = new Random(234);
    for (ImageType type : new ImageType[] { ImageType.SB_U8, ImageType.SB_F32 }) {
        ImageGray input = (ImageGray) type.createImage(w, h);
        InterleavedU16 found = new InterleavedU16(w, h, 2);
        InterleavedU16 expected = new InterleavedU16(w, h, 2);
        ImageBorder border = FactoryImageBorder.wrap(BorderType.EXTENDED, input);
        DogArray<Point2D_I32> samples5x5 = createSamples(2);
        if (type.getDataType().isInteger()) {
            GImageMiscOps.fillUniform(input, rand, 0, 255);
            ImplCensusTransformBorder.sample_IU16((ImageBorder_S32) border, 2, samples5x5, found);
        } else {
            GImageMiscOps.fillUniform(input, rand, -2, 2);
            ImplCensusTransformBorder.sample_IU16((ImageBorder_F32) border, 2, samples5x5, found);
        }
        CensusNaive.sample(input, samples5x5, expected);
        BoofTesting.assertEqualsBorder(expected, found, 0.0, 2, 2);
    }
}
Also used : Random(java.util.Random) Point2D_I32(georegression.struct.point.Point2D_I32) ImageBorder(boofcv.struct.border.ImageBorder) FactoryImageBorder(boofcv.core.image.border.FactoryImageBorder) Test(org.junit.jupiter.api.Test)

Example 12 with ImageBorder

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

the class TestInterpolatePixel_S_to_MB method checkFunctions.

@Test
void checkFunctions() {
    Helper helper = new Helper();
    InterpolatePixelMB alg = new InterpolatePixel_S_to_MB(helper);
    float[] pixel = new float[1];
    assertEquals(1, alg.getImageType().getNumBands());
    alg.get(2, 3, pixel);
    assertEquals(2, pixel[0], 1e-8);
    alg.get_fast(2, 3, pixel);
    assertEquals(3, pixel[0], 1e-8);
    assertTrue(alg.isInFastBounds(20, 4));
    assertFalse(alg.isInFastBounds(0, 4));
    assertEquals(10, alg.getFastBorderX());
    assertEquals(11, alg.getFastBorderY());
    ImageBorder border = FactoryImageBorder.genericValue(0, alg.getImageType());
    alg.setBorder(border);
    assertTrue(border == alg.getBorder());
}
Also used : FactoryImageBorder(boofcv.core.image.border.FactoryImageBorder) ImageBorder(boofcv.struct.border.ImageBorder) Test(org.junit.jupiter.api.Test)

Example 13 with ImageBorder

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

the class TestConvolveImageBox method reformatForValidation.

@Override
protected Object[] reformatForValidation(Method m, Object[] targetParam) {
    Class<?>[] params = m.getParameterTypes();
    Object kernel = TestConvolveImageBox.createTableKernel(params[0], kernelRadius, rand);
    ImageGray output = (ImageGray) ((ImageGray) targetParam[1]).clone();
    ImageBorder border = output.getDataType().isInteger() ? new ImageBorderValue.Value_I(0) : new ImageBorderValue.Value_F32(0);
    return new Object[] { kernel, targetParam[0], output, border };
}
Also used : ImageGray(boofcv.struct.image.ImageGray) ImageBorderValue(boofcv.core.image.ImageBorderValue) ImageBorder(boofcv.struct.border.ImageBorder)

Example 14 with ImageBorder

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

the class TestConvolveJustBorder_General_SB method reformatForValidation.

@Override
protected Object[] reformatForValidation(Method m, Object[] targetParam) {
    Object[] ret = new Object[Math.max(m.getParameterTypes().length, targetParam.length)];
    System.arraycopy(targetParam, 0, ret, 0, targetParam.length);
    ImageBorder border = (ImageBorder) targetParam[1];
    ImageGray inputImage = (ImageGray) border.getImage();
    KernelBase kernel = (KernelBase) targetParam[0];
    computeBorder(kernel, m.getName());
    int borderWidthX = borderX0 + borderX1;
    int borderWidthY = borderY0 + borderY1;
    // input image
    ret[1] = inputImage.createNew(width + borderWidthX, height + borderWidthY);
    // output image
    ret[2] = ((ImageGray) targetParam[2]).createNew(width + borderWidthX, height + borderWidthY);
    GImageMiscOps.growBorder(inputImage, border, borderX0, borderY0, borderX1, borderY1, (ImageBase) ret[1]);
    return ret;
}
Also used : GImageGray(boofcv.core.image.GImageGray) FactoryGImageGray(boofcv.core.image.FactoryGImageGray) ImageGray(boofcv.struct.image.ImageGray) KernelBase(boofcv.struct.convolve.KernelBase) ImageBorder(boofcv.struct.border.ImageBorder) FactoryImageBorder(boofcv.core.image.border.FactoryImageBorder)

Aggregations

ImageBorder (boofcv.struct.border.ImageBorder)14 FactoryImageBorder (boofcv.core.image.border.FactoryImageBorder)12 Test (org.junit.jupiter.api.Test)7 ImageGray (boofcv.struct.image.ImageGray)5 Random (java.util.Random)4 KernelBase (boofcv.struct.convolve.KernelBase)2 Point2D_I32 (georegression.struct.point.Point2D_I32)2 ImageGradient (boofcv.abst.filter.derivative.ImageGradient)1 FactoryGImageGray (boofcv.core.image.FactoryGImageGray)1 GImageGray (boofcv.core.image.GImageGray)1 ImageBorderValue (boofcv.core.image.ImageBorderValue)1 ImageBorder_F32 (boofcv.struct.border.ImageBorder_F32)1 ImageBorder_S32 (boofcv.struct.border.ImageBorder_S32)1 Kernel2D (boofcv.struct.convolve.Kernel2D)1 GrayF32 (boofcv.struct.image.GrayF32)1 GrayI (boofcv.struct.image.GrayI)1 ImageBase (boofcv.struct.image.ImageBase)1 GradientValue (boofcv.struct.sparse.GradientValue)1 SparseImageGradient (boofcv.struct.sparse.SparseImageGradient)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1