Search in sources :

Example 21 with GImageGray

use of boofcv.core.image.GImageGray in project BoofCV by lessthanoptimal.

the class BaseTestDescribePointBinaryCompare method testManualCheck.

/**
 * Compute the descriptor manually and see if it gets the same answer
 */
@Test
public void testManualCheck() {
    T input = createImage(width, height);
    GImageGray a = FactoryGImageGray.wrap(input);
    DescribePointBinaryCompare<T> alg = createAlg(def);
    alg.setImage(input);
    int c_x = input.width / 2;
    int c_y = input.height / 2;
    TupleDesc_B desc = createFeature();
    alg.process(c_x, c_y, desc);
    for (int i = 0; i < def.compare.length; i++) {
        Point2D_I32 c = def.compare[i];
        Point2D_I32 p0 = def.samplePoints[c.x];
        Point2D_I32 p1 = def.samplePoints[c.y];
        boolean expected = a.get(c_x + p0.x, c_y + p0.y).doubleValue() < a.get(c_x + p1.x, c_y + p1.y).doubleValue();
        assertTrue(expected == desc.isBitTrue(def.compare.length - i - 1));
    }
}
Also used : TupleDesc_B(boofcv.struct.feature.TupleDesc_B) GImageGray(boofcv.core.image.GImageGray) FactoryGImageGray(boofcv.core.image.FactoryGImageGray) Point2D_I32(georegression.struct.point.Point2D_I32) Test(org.junit.Test)

Example 22 with GImageGray

use of boofcv.core.image.GImageGray in project BoofCV by lessthanoptimal.

the class TestImplSurfDescribeOps method createGradient.

/**
 * Creates an image with a constant gradient in the specified direction
 */
public static <I extends ImageGray<I>> void createGradient(double theta, I image) {
    GImageGray ret = FactoryGImageGray.wrap(image);
    double c = Math.cos(theta);
    double s = Math.sin(theta);
    for (int y = 0; y < image.height; y++) {
        for (int x = 0; x < image.width; x++) {
            double xx = c * x;
            double yy = s * y;
            ret.set(x, y, (float) (xx + yy));
        }
    }
}
Also used : GImageGray(boofcv.core.image.GImageGray) FactoryGImageGray(boofcv.core.image.FactoryGImageGray)

Example 23 with GImageGray

use of boofcv.core.image.GImageGray in project BoofCV by lessthanoptimal.

the class TestImplWaveletTransformInner method equalsTranHorizontal.

/**
 * Compares two wavelet transformations while ignoring the input image borders.  Input borders
 * affect the borders of internal segments inside the transformation.
 */
private void equalsTranHorizontal(ImageGray expected, ImageGray found, int begin, int end, String quad) {
    GImageGray e = FactoryGImageGray.wrap(expected);
    GImageGray f = FactoryGImageGray.wrap(found);
    for (int y = 0; y < expected.height; y++) {
        for (int x = 0; x < expected.width; x++) {
            // the border should be unmodified, zeros
            if (x >= begin && x < end)
                assertEquals(quad + " ( " + x + " , " + y + " )", e.get(x, y).floatValue(), f.get(x, y).floatValue(), 1e-4f);
            else
                assertTrue(quad + " ( " + x + " , " + y + " ) 0 != " + f.get(x, y), 0 == f.get(x, y).floatValue());
        }
    }
}
Also used : FactoryGImageGray(boofcv.core.image.FactoryGImageGray) GImageGray(boofcv.core.image.GImageGray)

Example 24 with GImageGray

use of boofcv.core.image.GImageGray in project BoofCV by lessthanoptimal.

the class TestImageMiscOps method testFillUniform_Single.

private void testFillUniform_Single(Method m) throws InvocationTargetException, IllegalAccessException {
    Class[] paramTypes = m.getParameterTypes();
    ImageGray orig = GeneralizedImageOps.createSingleBand(paramTypes[0], width, height);
    if (orig.getDataType().isInteger()) {
        if (orig.getDataType().isSigned())
            m.invoke(null, orig, rand, -10, 10);
        else {
            m.invoke(null, orig, rand, 1, 10);
        }
    } else {
        m.invoke(null, orig, rand, -10, 10);
    }
    int numZero = 0;
    GImageGray a = FactoryGImageGray.wrap(orig);
    for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
            double value = a.get(j, i).doubleValue();
            assertTrue("value = " + value, value >= -10 && value < 10);
            if (value == 0)
                numZero++;
        }
    }
    assertTrue(numZero < width * height);
}
Also used : FactoryGImageGray(boofcv.core.image.FactoryGImageGray) GImageGray(boofcv.core.image.GImageGray) FactoryGImageGray(boofcv.core.image.FactoryGImageGray) ImageGray(boofcv.struct.image.ImageGray) GImageGray(boofcv.core.image.GImageGray)

Example 25 with GImageGray

use of boofcv.core.image.GImageGray in project BoofCV by lessthanoptimal.

the class TestImageMiscOps method testFillBorder.

private void testFillBorder(Method m) throws InvocationTargetException, IllegalAccessException {
    Class[] paramTypes = m.getParameterTypes();
    ImageGray orig = GeneralizedImageOps.createSingleBand(paramTypes[0], width, height);
    GImageMiscOps.fill(orig, 4);
    int r = 2;
    if (orig.getDataType().isInteger()) {
        m.invoke(null, orig, 5, r);
    } else {
        m.invoke(null, orig, 5, r);
    }
    GImageGray a = FactoryGImageGray.wrap(orig);
    for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
            if (j < r || i < r || j >= width - r || i >= height - r)
                assertEquals(i + " " + j, 5, a.get(j, i).doubleValue(), 1e-4);
            else
                assertEquals(4, a.get(j, i).doubleValue(), 1e-4);
        }
    }
}
Also used : FactoryGImageGray(boofcv.core.image.FactoryGImageGray) GImageGray(boofcv.core.image.GImageGray) FactoryGImageGray(boofcv.core.image.FactoryGImageGray) ImageGray(boofcv.struct.image.ImageGray) GImageGray(boofcv.core.image.GImageGray)

Aggregations

FactoryGImageGray (boofcv.core.image.FactoryGImageGray)35 GImageGray (boofcv.core.image.GImageGray)35 ImageGray (boofcv.struct.image.ImageGray)17 Test (org.junit.Test)5 Bitmap (android.graphics.Bitmap)3 TupleDesc_B (boofcv.struct.feature.TupleDesc_B)2 Point2D_I32 (georegression.struct.point.Point2D_I32)2 IntegralKernel (boofcv.alg.transform.ii.IntegralKernel)1 ImageRectangle (boofcv.struct.ImageRectangle)1 GrayF32 (boofcv.struct.image.GrayF32)1 GrayU8 (boofcv.struct.image.GrayU8)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1