Search in sources :

Example 66 with ImageGray

use of boofcv.struct.image.ImageGray in project BoofCV by lessthanoptimal.

the class TestImageMiscOps method testFillGaussian_Single.

private void testFillGaussian_Single(Method m) throws InvocationTargetException, IllegalAccessException {
    Class[] paramTypes = m.getParameterTypes();
    ImageGray orig = GeneralizedImageOps.createSingleBand(paramTypes[0], width, height);
    if (orig.getDataType().isSigned())
        m.invoke(null, orig, rand, 0, 5, -2, 2);
    else {
        m.invoke(null, orig, rand, 5, 7, 0, 12);
    }
    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();
            if (orig.getDataType().isSigned()) {
                assertTrue("value = " + value, value >= -2 && value <= 2);
            } else {
                assertTrue("value = " + value, value >= 0 && value <= 12);
            }
            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 67 with ImageGray

use of boofcv.struct.image.ImageGray in project BoofCV by lessthanoptimal.

the class TestImageMiscOps method testAddUniform_Single.

private void testAddUniform_Single(Method m) throws InvocationTargetException, IllegalAccessException {
    Class[] paramTypes = m.getParameterTypes();
    ImageGray orig = GeneralizedImageOps.createSingleBand(paramTypes[0], width, height);
    GImageMiscOps.fill(orig, 1);
    if (orig.getDataType().isInteger()) {
        m.invoke(null, orig, rand, 1, 10);
    } else {
        m.invoke(null, orig, rand, 1, 10);
    }
    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 >= -2 && value <= 11);
        }
    }
}
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 68 with ImageGray

use of boofcv.struct.image.ImageGray in project BoofCV by lessthanoptimal.

the class TestImageMiscOps method testRotateCW_one.

public void testRotateCW_one(Method m) throws InvocationTargetException, IllegalAccessException {
    Class[] paramTypes = m.getParameterTypes();
    // test even and odd width
    for (int i = 0; i < 2; i++) {
        int w = 6 + i;
        ImageGray orig = GeneralizedImageOps.createSingleBand(paramTypes[0], w, w);
        GImageMiscOps.fillUniform(orig, rand, 0, 10);
        ImageGray rotated = (ImageGray) orig.clone();
        m.invoke(null, rotated);
        for (int y = 0; y < w; y++) {
            for (int x = 0; x < w; x++) {
                double expected = GeneralizedImageOps.get(orig, x, y);
                double found = GeneralizedImageOps.get(rotated, w - y - 1, x);
                assertEquals(x + " " + y, expected, found, 1e-8);
            }
        }
    }
}
Also used : FactoryGImageGray(boofcv.core.image.FactoryGImageGray) ImageGray(boofcv.struct.image.ImageGray) GImageGray(boofcv.core.image.GImageGray)

Example 69 with ImageGray

use of boofcv.struct.image.ImageGray in project BoofCV by lessthanoptimal.

the class TestImageMiscOps method testFlipHorizontal.

private void testFlipHorizontal(Method m, int width) throws IllegalAccessException, InvocationTargetException {
    Class[] paramTypes = m.getParameterTypes();
    ImageGray imgA = GeneralizedImageOps.createSingleBand(paramTypes[0], width, height);
    GImageMiscOps.fillUniform(imgA, rand, 0, 100);
    ImageGray imgB = (ImageGray) imgA.clone();
    m.invoke(null, imgB);
    for (int y = 0; y < height; y++) {
        for (int x = 0; x < width; x++) {
            double valA = GeneralizedImageOps.get(imgA, width - x - 1, y);
            double valB = GeneralizedImageOps.get(imgB, x, y);
            assertTrue(valA == valB);
        }
    }
}
Also used : FactoryGImageGray(boofcv.core.image.FactoryGImageGray) ImageGray(boofcv.struct.image.ImageGray) GImageGray(boofcv.core.image.GImageGray)

Example 70 with ImageGray

use of boofcv.struct.image.ImageGray in project BoofCV by lessthanoptimal.

the class TestImageMiscOps method testRotateCCW_one.

public void testRotateCCW_one(Method m) throws InvocationTargetException, IllegalAccessException {
    Class[] paramTypes = m.getParameterTypes();
    // test even and odd width
    for (int i = 0; i < 2; i++) {
        int w = 6 + i;
        ImageGray orig = GeneralizedImageOps.createSingleBand(paramTypes[0], w, w);
        GImageMiscOps.fillUniform(orig, rand, 0, 10);
        ImageGray rotated = (ImageGray) orig.clone();
        m.invoke(null, rotated);
        for (int y = 0; y < w; y++) {
            for (int x = 0; x < w; x++) {
                double expected = GeneralizedImageOps.get(orig, x, y);
                double found = GeneralizedImageOps.get(rotated, y, w - x - 1);
                assertEquals(expected, found, 1e-8);
            }
        }
    }
}
Also used : FactoryGImageGray(boofcv.core.image.FactoryGImageGray) ImageGray(boofcv.struct.image.ImageGray) GImageGray(boofcv.core.image.GImageGray)

Aggregations

ImageGray (boofcv.struct.image.ImageGray)110 FactoryGImageGray (boofcv.core.image.FactoryGImageGray)43 GImageGray (boofcv.core.image.GImageGray)43 Test (org.junit.Test)26 GrayF32 (boofcv.struct.image.GrayF32)20 Method (java.lang.reflect.Method)17 GrayU8 (boofcv.struct.image.GrayU8)15 Bitmap (android.graphics.Bitmap)4 ImageBorder_S32 (boofcv.core.image.border.ImageBorder_S32)4 GrayS16 (boofcv.struct.image.GrayS16)4 GrayS32 (boofcv.struct.image.GrayS32)4 Planar (boofcv.struct.image.Planar)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 IntegralKernel (boofcv.alg.transform.ii.IntegralKernel)3 ImageRectangle (boofcv.struct.ImageRectangle)3 FDistort (boofcv.abst.distort.FDistort)2 ImageBorder_F32 (boofcv.core.image.border.ImageBorder_F32)2 FactoryDescribeImageDense (boofcv.factory.feature.dense.FactoryDescribeImageDense)2 Kernel2D_S32 (boofcv.struct.convolve.Kernel2D_S32)2 TupleDesc_F64 (boofcv.struct.feature.TupleDesc_F64)2