Search in sources :

Example 6 with ImageBase

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

the class TestImageStatistics method testMaxAbs.

private void testMaxAbs(Method m) throws InvocationTargetException, IllegalAccessException {
    Class[] paramTypes = m.getParameterTypes();
    ImageBase input = GeneralizedImageOps.createImage(paramTypes[0], width, height, numBands);
    if (input.getImageType().getDataType().isSigned()) {
        GImageMiscOps.fillUniform(input, rand, -20, 19);
        GeneralizedImageOps.setB(input, 0, 3, 0, -100);
    } else {
        GImageMiscOps.fillUniform(input, rand, 0, 19);
        GeneralizedImageOps.setB(input, 0, 3, 0, 100);
    }
    Number o = (Number) m.invoke(null, input);
    assertEquals(100, o.doubleValue(), 1e-8);
}
Also used : ImageBase(boofcv.struct.image.ImageBase)

Example 7 with ImageBase

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

the class TestImageStatistics method testMin.

private void testMin(Method m) throws InvocationTargetException, IllegalAccessException {
    Class[] paramTypes = m.getParameterTypes();
    ImageBase input = GeneralizedImageOps.createImage(paramTypes[0], width, height, numBands);
    if (input.getImageType().getDataType().isSigned()) {
        GImageMiscOps.fillUniform(input, rand, -20, -5);
        GeneralizedImageOps.setB(input, 0, 3, 0, -30);
        Number o = (Number) m.invoke(null, input);
        assertEquals(-30, o.doubleValue(), 1e-8);
    } else {
        double maxValue = input.getImageType().getDataType().getMaxValue();
        GImageMiscOps.fillUniform(input, rand, 100, maxValue);
        for (int y = 0; y < height; y++) {
            for (int x = 0; x < width; x++) {
                double before = GeneralizedImageOps.get(input, x, y, 0);
                GeneralizedImageOps.setB(input, x, y, 0, 5);
                Number o = (Number) m.invoke(null, input);
                assertEquals(5, o.doubleValue(), 1e-8);
                GeneralizedImageOps.setB(input, x, y, 0, before);
            }
        }
    }
}
Also used : ImageBase(boofcv.struct.image.ImageBase)

Example 8 with ImageBase

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

the class TestImageStatistics method testSum.

private void testSum(Method m) throws InvocationTargetException, IllegalAccessException {
    Class[] paramTypes = m.getParameterTypes();
    ImageBase inputA = GeneralizedImageOps.createImage(paramTypes[0], width, height, numBands);
    int numBands = inputA.getImageType().getNumBands();
    if (inputA.getImageType().getDataType().isSigned()) {
        GImageMiscOps.fillUniform(inputA, rand, -20, 20);
    } else {
        GImageMiscOps.fillUniform(inputA, rand, 0, 20);
    }
    Object result = m.invoke(null, inputA);
    double expected = 0;
    for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
            for (int k = 0; k < numBands; k++) {
                expected += GeneralizedImageOps.get(inputA, j, i, k);
            }
        }
    }
    double found = ((Number) result).doubleValue();
    assertEquals(expected, found, 1e-3);
}
Also used : ImageBase(boofcv.struct.image.ImageBase)

Example 9 with ImageBase

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

the class TestPixelMath method testInvert.

private void testInvert(Method m) throws InvocationTargetException, IllegalAccessException {
    Class[] paramTypes = m.getParameterTypes();
    ImageBase inputA = GeneralizedImageOps.createImage(paramTypes[0], width, height, numBands);
    ImageBase inputB = GeneralizedImageOps.createImage(paramTypes[1], width, height, numBands);
    int numBands = inputA.getImageType().getNumBands();
    if (inputA.getImageType().getDataType().isSigned()) {
        GImageMiscOps.fillUniform(inputA, rand, -20, 20);
    } else {
        throw new RuntimeException("Shouldn't be used on unsigned images");
    }
    m.invoke(null, inputA, inputB);
    for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
            for (int k = 0; k < numBands; k++) {
                double a = GeneralizedImageOps.get(inputA, j, i, k);
                double b = GeneralizedImageOps.get(inputB, j, i, k);
                assertEquals(a, -b, 1e-4);
            }
        }
    }
}
Also used : ImageBase(boofcv.struct.image.ImageBase)

Example 10 with ImageBase

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

the class TestPixelMath method testDivideBounded.

private void testDivideBounded(Method m) throws InvocationTargetException, IllegalAccessException {
    Class[] paramTypes = m.getParameterTypes();
    ImageBase input = GeneralizedImageOps.createImage(paramTypes[0], width, height, numBands);
    ImageBase output = GeneralizedImageOps.createImage(paramTypes[4], width, height, numBands);
    GImageMiscOps.fillUniform(input, rand, 0, 20);
    int numBands = input.getImageType().getNumBands();
    if (input.getImageType().getDataType().isSigned()) {
        GImageMiscOps.fillUniform(input, rand, -20, 20);
    } else {
        GImageMiscOps.fillUniform(input, rand, 0, 20);
    }
    if (input.getImageType().getDataType().isInteger())
        m.invoke(null, input, 10, -1, 1, output);
    else
        m.invoke(null, input, 10.0f, -1f, 1f, output);
    float tol = input.getImageType().getDataType().isInteger() ? 1 : 1e-4f;
    for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
            for (int k = 0; k < numBands; k++) {
                double expected = GeneralizedImageOps.get(input, j, i, k) / 10.0f;
                double found = GeneralizedImageOps.get(output, j, i, k);
                if (expected < -1)
                    expected = -1;
                if (expected > 1)
                    expected = 1;
                assertEquals(expected, found, tol);
            }
        }
    }
}
Also used : ImageBase(boofcv.struct.image.ImageBase)

Aggregations

ImageBase (boofcv.struct.image.ImageBase)54 ImageType (boofcv.struct.image.ImageType)14 Test (org.junit.Test)13 Se3_F64 (georegression.struct.se.Se3_F64)5 BufferedImage (java.awt.image.BufferedImage)5 SimpleImageSequence (boofcv.io.image.SimpleImageSequence)4 GrayU8 (boofcv.struct.image.GrayU8)4 MediaManager (boofcv.io.MediaManager)3 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)3 DefaultMediaManager (boofcv.io.wrapper.DefaultMediaManager)3 KernelBase (boofcv.struct.convolve.KernelBase)3 Point2D_F64 (georegression.struct.point.Point2D_F64)3 ConfigBackgroundBasic (boofcv.factory.background.ConfigBackgroundBasic)2 ConfigBackgroundGmm (boofcv.factory.background.ConfigBackgroundGmm)2 ImageGridPanel (boofcv.gui.image.ImageGridPanel)2 ImagePanel (boofcv.gui.image.ImagePanel)2 GrayF32 (boofcv.struct.image.GrayF32)2 Planar (boofcv.struct.image.Planar)2 File (java.io.File)2 FDistort (boofcv.abst.distort.FDistort)1