Search in sources :

Example 6 with ImageBorder1D_S32

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

the class StandardGradientChecks method testSecondDerivative.

/**
 * The XY and YX second derivatives should be indential
 */
private void testSecondDerivative(Method m1, Method m2) {
    Class[] params = m1.getParameterTypes();
    ImageGray input = GeneralizedImageOps.createSingleBand(params[0], width, height);
    ImageGray derivX = GeneralizedImageOps.createSingleBand(params[1], width, height);
    ImageGray derivY = GeneralizedImageOps.createSingleBand(params[2], width, height);
    ImageGray derivXX = GeneralizedImageOps.createSingleBand(params[1], width, height);
    ImageGray derivYY = GeneralizedImageOps.createSingleBand(params[2], width, height);
    ImageGray derivXY = GeneralizedImageOps.createSingleBand(params[1], width, height);
    ImageGray derivYX = GeneralizedImageOps.createSingleBand(params[1], width, height);
    GImageMiscOps.fillUniform(input, rand, 0, 40);
    Object border;
    if (params[3] == ImageBorder_F32.class) {
        border = new ImageBorder1D_F32(BorderIndex1D_Wrap.class);
    } else {
        border = new ImageBorder1D_S32(BorderIndex1D_Wrap.class);
    }
    try {
        m1.invoke(null, input, derivX, derivY, border);
        m2.invoke(null, derivX, derivXX, derivXY, border);
        m2.invoke(null, derivY, derivYX, derivYY, border);
    } catch (IllegalAccessException | InvocationTargetException e) {
        throw new RuntimeException(e);
    }
    // BoofTesting.printDiff(derivXY,derivYX);
    BoofTesting.assertEquals(derivXY, derivYX, 1e-3f);
}
Also used : BorderIndex1D_Wrap(boofcv.core.image.border.BorderIndex1D_Wrap) ImageBorder1D_F32(boofcv.core.image.border.ImageBorder1D_F32) ImageGray(boofcv.struct.image.ImageGray) ImageBorder1D_S32(boofcv.core.image.border.ImageBorder1D_S32) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 7 with ImageBorder1D_S32

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

the class TestImplShiTomasiCorner_F32 method compareToNaive.

/**
 * Sees if the integer version and this version produce the same results.
 * <p/>
 * Creates a random image and looks for corners in it.  Sees if the naive
 * and fast algorithm produce exactly the same results.
 */
@Test
public void compareToNaive() {
    GrayU8 img = new GrayU8(width, height);
    ImageMiscOps.fillUniform(img, new Random(0xfeed), 0, 100);
    GrayS16 derivX_I = new GrayS16(img.getWidth(), img.getHeight());
    GrayS16 derivY_I = new GrayS16(img.getWidth(), img.getHeight());
    GradientSobel.process(img, derivX_I, derivY_I, new ImageBorder1D_S32(BorderIndex1D_Extend.class));
    GrayF32 derivX_F = ConvertImage.convert(derivX_I, (GrayF32) null);
    GrayF32 derivY_F = ConvertImage.convert(derivY_I, (GrayF32) null);
    BoofTesting.checkSubImage(this, "compareToNaive", true, derivX_F, derivY_F);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) Random(java.util.Random) GrayS16(boofcv.struct.image.GrayS16) GrayU8(boofcv.struct.image.GrayU8) ImageBorder1D_S32(boofcv.core.image.border.ImageBorder1D_S32) BorderIndex1D_Extend(boofcv.core.image.border.BorderIndex1D_Extend) Test(org.junit.Test)

Aggregations

ImageBorder1D_S32 (boofcv.core.image.border.ImageBorder1D_S32)7 BorderIndex1D_Extend (boofcv.core.image.border.BorderIndex1D_Extend)6 Test (org.junit.Test)6 GrayS16 (boofcv.struct.image.GrayS16)4 GrayU8 (boofcv.struct.image.GrayU8)4 Random (java.util.Random)4 GrayF32 (boofcv.struct.image.GrayF32)2 BorderIndex1D_Wrap (boofcv.core.image.border.BorderIndex1D_Wrap)1 ImageBorder1D_F32 (boofcv.core.image.border.ImageBorder1D_F32)1 Kernel1D_S32 (boofcv.struct.convolve.Kernel1D_S32)1 Kernel2D_S32 (boofcv.struct.convolve.Kernel2D_S32)1 ImageGray (boofcv.struct.image.ImageGray)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1