Search in sources :

Example 26 with ImageGray

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

the class TestImageMiscOps method testInsertBand.

private void testInsertBand(Method m) throws InvocationTargetException, IllegalAccessException {
    Class[] paramTypes = m.getParameterTypes();
    ImageGray input = GeneralizedImageOps.createSingleBand(paramTypes[0], width, height);
    ImageInterleaved output = GeneralizedImageOps.createInterleaved(paramTypes[2], width, height, numBands);
    GImageMiscOps.fillUniform(input, rand, 0, 20);
    for (int band = 0; band < numBands; band++) {
        GImageMiscOps.fillUniform(output, rand, 0, 20);
        m.invoke(null, input, band, output);
        int numMatch = 0;
        for (int i = 0; i < height; i++) {
            for (int j = 0; j < width; j++) {
                double valueIn = GeneralizedImageOps.get(input, j, i);
                for (int k = 0; k < numBands; k++) {
                    double valueOut = GeneralizedImageOps.get(output, j, i, k);
                    if (k == band) {
                        assertEquals(valueIn, valueOut, 1e-4);
                    } else {
                        if (valueIn == valueOut)
                            numMatch++;
                    }
                }
            }
        }
        assertFalse(numMatch > width * height * (numBands - 1) / 5);
    }
}
Also used : ImageInterleaved(boofcv.struct.image.ImageInterleaved) FactoryGImageGray(boofcv.core.image.FactoryGImageGray) ImageGray(boofcv.struct.image.ImageGray) GImageGray(boofcv.core.image.GImageGray)

Example 27 with ImageGray

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

the class TestImageMiscOps method testRotateCCW_two.

public void testRotateCCW_two(Method m) throws InvocationTargetException, IllegalAccessException {
    Class[] paramTypes = m.getParameterTypes();
    ImageGray a = GeneralizedImageOps.createSingleBand(paramTypes[0], 3, 2);
    ImageGray b = GeneralizedImageOps.createSingleBand(paramTypes[0], 2, 3);
    for (int i = 0; i < 6; i++) {
        GeneralizedImageOps.set(a, i % 3, i / 3, i);
    }
    m.invoke(null, a, b);
    assertEquals(2, GeneralizedImageOps.get(b, 0, 0), 1e-8);
    assertEquals(5, GeneralizedImageOps.get(b, 1, 0), 1e-8);
    assertEquals(1, GeneralizedImageOps.get(b, 0, 1), 1e-8);
    assertEquals(4, GeneralizedImageOps.get(b, 1, 1), 1e-8);
    assertEquals(0, GeneralizedImageOps.get(b, 0, 2), 1e-8);
    assertEquals(3, GeneralizedImageOps.get(b, 1, 2), 1e-8);
}
Also used : FactoryGImageGray(boofcv.core.image.FactoryGImageGray) ImageGray(boofcv.struct.image.ImageGray) GImageGray(boofcv.core.image.GImageGray)

Example 28 with ImageGray

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

the class TestImageMiscOps method testFill_Single.

private void testFill_Single(Method m) throws InvocationTargetException, IllegalAccessException {
    Class[] paramTypes = m.getParameterTypes();
    ImageGray orig = GeneralizedImageOps.createSingleBand(paramTypes[0], width, height);
    GImageMiscOps.fillUniform(orig, rand, 0, 20);
    if (orig.getDataType().isInteger()) {
        m.invoke(null, orig, 10);
    } else {
        m.invoke(null, orig, 10.0f);
    }
    GImageGray a = FactoryGImageGray.wrap(orig);
    for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
            assertEquals(10.0, 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)

Example 29 with ImageGray

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

the class TestImageMiscOps method testRotateCW_two.

public void testRotateCW_two(Method m) throws InvocationTargetException, IllegalAccessException {
    Class[] paramTypes = m.getParameterTypes();
    ImageGray a = GeneralizedImageOps.createSingleBand(paramTypes[0], 3, 2);
    ImageGray b = GeneralizedImageOps.createSingleBand(paramTypes[0], 2, 3);
    for (int i = 0; i < 6; i++) {
        GeneralizedImageOps.set(a, i % 3, i / 3, i);
    }
    m.invoke(null, a, b);
    assertEquals(3, GeneralizedImageOps.get(b, 0, 0), 1e-8);
    assertEquals(0, GeneralizedImageOps.get(b, 1, 0), 1e-8);
    assertEquals(4, GeneralizedImageOps.get(b, 0, 1), 1e-8);
    assertEquals(1, GeneralizedImageOps.get(b, 1, 1), 1e-8);
    assertEquals(5, GeneralizedImageOps.get(b, 0, 2), 1e-8);
    assertEquals(2, GeneralizedImageOps.get(b, 1, 2), 1e-8);
}
Also used : FactoryGImageGray(boofcv.core.image.FactoryGImageGray) ImageGray(boofcv.struct.image.ImageGray) GImageGray(boofcv.core.image.GImageGray)

Example 30 with ImageGray

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

the class TestImageStatistics method testHistogram.

private void testHistogram(Method m) throws InvocationTargetException, IllegalAccessException {
    Class[] paramTypes = m.getParameterTypes();
    ImageGray inputA = GeneralizedImageOps.createSingleBand(paramTypes[0], width, height);
    int[] histogram = new int[40];
    // it should be zeroed
    for (int i = 0; i < histogram.length; i++) histogram[i] = 100;
    int minValue;
    if (inputA.getDataType().isSigned()) {
        minValue = -20;
        GImageMiscOps.fillUniform(inputA, rand, minValue, 19);
        m.invoke(null, inputA, minValue, histogram);
    } else {
        minValue = 5;
        GImageMiscOps.fillUniform(inputA, rand, minValue, minValue + histogram.length - 1);
        m.invoke(null, inputA, minValue, histogram);
    }
    // manually compute the histogram
    int[] expected = new int[histogram.length];
    for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
            double a = GeneralizedImageOps.get(inputA, j, i);
            expected[(int) (-minValue + a)]++;
        }
    }
    for (int i = 0; i < 40; i++) {
        assertEquals("index " + i, expected[i], histogram[i]);
    }
}
Also used : ImageGray(boofcv.struct.image.ImageGray)

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