Search in sources :

Example 11 with ImageBase

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

the class TestPixelMath method testMultiplyBounded.

private void testMultiplyBounded(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, 2, -30, 30, output);
    else
        m.invoke(null, input, 2.0f, -30f, 30f, output);
    float tol = input.getImageType().getDataType().isInteger() ? 1 : 1e-4f;
    GImageMultiBand a = FactoryGImageMultiBand.wrap(input);
    GImageMultiBand b = FactoryGImageMultiBand.wrap(output);
    for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
            a.get(j, i, pixelA);
            b.get(j, i, pixelB);
            for (int k = 0; k < numBands; k++) {
                float expected = pixelA[k] * 2;
                float found = pixelB[k];
                if (expected < -30)
                    expected = -30;
                if (expected > 30)
                    expected = 30;
                assertEquals(expected, found, tol);
            }
        }
    }
}
Also used : ImageBase(boofcv.struct.image.ImageBase)

Example 12 with ImageBase

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

the class TestPixelMath method testMinus.

private void testMinus(Method m) throws InvocationTargetException, IllegalAccessException {
    Class[] paramTypes = m.getParameterTypes();
    boolean imageFirst = ImageBase.class.isAssignableFrom(paramTypes[0]);
    int indexImg = imageFirst ? 0 : 1;
    ImageBase input = GeneralizedImageOps.createImage(paramTypes[indexImg], width, height, numBands);
    ImageBase output = GeneralizedImageOps.createImage(paramTypes[indexImg], width, height, numBands);
    int numBands = input.getImageType().getNumBands();
    float val = imageFirst ? 2 : 20;
    Object scalar;
    if (input.getImageType().getDataType().isInteger()) {
        if (imageFirst) {
            GImageMiscOps.fillUniform(input, rand, 10, 25);
        } else {
            GImageMiscOps.fillUniform(input, rand, 3, 10);
        }
        scalar = (int) val;
    } else {
        GImageMiscOps.fillUniform(input, rand, -20, 20);
        scalar = val;
    }
    Object[] args = imageFirst ? new Object[] { input, scalar, output } : new Object[] { scalar, input, output };
    m.invoke(null, args);
    GImageMultiBand a = FactoryGImageMultiBand.wrap(input);
    GImageMultiBand b = FactoryGImageMultiBand.wrap(output);
    float tol = input.getImageType().getDataType().isInteger() ? 1 : 1e-4f;
    for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
            a.get(j, i, pixelA);
            b.get(j, i, pixelB);
            for (int k = 0; k < numBands; k++) {
                if (imageFirst)
                    assertEquals(pixelA[k] - val, pixelB[k], tol);
                else
                    assertEquals(i + " " + j + " " + k, val - pixelA[k], pixelB[k], tol);
            }
        }
    }
}
Also used : ImageBase(boofcv.struct.image.ImageBase)

Example 13 with ImageBase

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

the class TestPixelMath method testMultiply.

private void testMultiply(Method m) throws InvocationTargetException, IllegalAccessException {
    Class[] paramTypes = m.getParameterTypes();
    ImageBase input = GeneralizedImageOps.createImage(paramTypes[0], width, height, numBands);
    ImageBase output = GeneralizedImageOps.createImage(paramTypes[2], 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, 2, output);
    else
        m.invoke(null, input, 2.0f, output);
    GImageMultiBand a = FactoryGImageMultiBand.wrap(input);
    GImageMultiBand b = FactoryGImageMultiBand.wrap(output);
    double tol = input.getImageType().getDataType().isInteger() ? 1 : 1e-4;
    for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
            a.get(j, i, pixelA);
            b.get(j, i, pixelB);
            for (int k = 0; k < numBands; k++) {
                assertEquals(pixelA[k] * 2, pixelB[k], tol);
            }
        }
    }
}
Also used : ImageBase(boofcv.struct.image.ImageBase)

Example 14 with ImageBase

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

the class TestPixelMath method testPlusBounded.

private void testPlusBounded(Method m) throws InvocationTargetException, IllegalAccessException {
    Class[] paramTypes = m.getParameterTypes();
    ImageBase input = GeneralizedImageOps.createImage(paramTypes[0], width, height, numBands);
    ImageBase output = GeneralizedImageOps.createImage(paramTypes[0], width, height, numBands);
    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, 2, -10, 12, output);
    else
        m.invoke(null, input, 2.0f, -10f, 12f, output);
    GImageMultiBand a = FactoryGImageMultiBand.wrap(input);
    GImageMultiBand b = FactoryGImageMultiBand.wrap(output);
    float tol = input.getImageType().getDataType().isInteger() ? 1 : 1e-4f;
    for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
            a.get(j, i, pixelA);
            b.get(j, i, pixelB);
            for (int k = 0; k < numBands; k++) {
                float expected = pixelA[k] + 2;
                float found = pixelB[k];
                if (expected < -10)
                    expected = -10;
                if (expected > 12)
                    expected = 12;
                assertEquals(i + " " + j + " " + k, expected, found, tol);
            }
        }
    }
}
Also used : ImageBase(boofcv.struct.image.ImageBase)

Example 15 with ImageBase

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

the class TestPixelMath method testDivide.

private void testDivide(Method m) throws InvocationTargetException, IllegalAccessException {
    Class[] paramTypes = m.getParameterTypes();
    ImageBase input = GeneralizedImageOps.createImage(paramTypes[0], width, height, numBands);
    ImageBase output = GeneralizedImageOps.createImage(paramTypes[2], width, height, numBands);
    int numBands = input.getImageType().getNumBands();
    GImageMiscOps.fillUniform(input, rand, 0, 20);
    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, output);
    else
        m.invoke(null, input, 10.0f, output);
    double tol = input.getImageType().getDataType().isInteger() ? 1 : 1e-4;
    for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
            for (int k = 0; k < numBands; k++) {
                double valA = GeneralizedImageOps.get(input, j, i, k);
                double valB = GeneralizedImageOps.get(output, j, i, k);
                assertEquals(valA / 10.0, valB, 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