Search in sources :

Example 6 with ImageInterleaved

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

the class TestImageMiscOps method testFillRectangle_Interleaved.

private void testFillRectangle_Interleaved(Method m) throws InvocationTargetException, IllegalAccessException {
    Class[] paramTypes = m.getParameterTypes();
    ImageInterleaved orig = GeneralizedImageOps.createInterleaved(paramTypes[0], width, height, 2);
    int x0 = 2;
    int y0 = 3;
    int width = 5;
    int height = 6;
    Class numParam = paramTypes[1];
    if (numParam == byte.class) {
        m.invoke(null, orig, (byte) 10, x0, y0, width, height);
    } else if (numParam == short.class) {
        m.invoke(null, orig, (short) 10, x0, y0, width, height);
    } else if (numParam == int.class) {
        m.invoke(null, orig, 10, x0, y0, width, height);
    } else if (numParam == long.class) {
        m.invoke(null, orig, (long) 10, x0, y0, width, height);
    } else {
        m.invoke(null, orig, 10.0f, x0, y0, width, height);
    }
    for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
            for (int band = 0; band < orig.numBands; band++) {
                double value = GeneralizedImageOps.get(orig, j, i, band);
                if (j < x0 || i < y0 || i >= (x0 + width) || j >= (y0 + height))
                    assertEquals(j + " " + i, 0.0, value, 1e-4);
                else
                    assertEquals(10.0, value, 1e-4);
            }
        }
    }
}
Also used : ImageInterleaved(boofcv.struct.image.ImageInterleaved)

Example 7 with ImageInterleaved

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

the class TestImageMiscOps method testFillUniform_Interleaved.

private void testFillUniform_Interleaved(Method m) throws InvocationTargetException, IllegalAccessException {
    Class[] paramTypes = m.getParameterTypes();
    ImageInterleaved orig = GeneralizedImageOps.createInterleaved(paramTypes[0], width, height, numBands);
    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;
    for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
            for (int band = 0; band < numBands; band++) {
                double value = GeneralizedImageOps.get(orig, j, i, band);
                assertTrue("value = " + value, value >= -10 && value < 10);
                if (value == 0)
                    numZero++;
            }
        }
    }
    assertTrue(numZero < width * height * numBands);
}
Also used : ImageInterleaved(boofcv.struct.image.ImageInterleaved)

Example 8 with ImageInterleaved

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

the class TestConvolveJustBorder_General_IL method compareResults.

@Override
protected void compareResults(Object targetResult, Object[] targetParam, Object validationResult, Object[] validationParam) {
    ImageInterleaved targetOut = (ImageInterleaved) targetParam[2];
    ImageInterleaved validationOut = (ImageInterleaved) validationParam[2];
    // remove the border
    computeBorder((KernelBase) targetParam[0], methodTest.getName());
    validationOut = (ImageInterleaved) stripBorder(validationOut, borderX0, borderY0, borderX1, borderY1);
    GImageMultiBand t = FactoryGImageMultiBand.wrap(targetOut);
    GImageMultiBand v = FactoryGImageMultiBand.wrap(validationOut);
    float[] pixelT = new float[t.getNumberOfBands()];
    float[] pixelV = new float[t.getNumberOfBands()];
    for (int y = 0; y < targetOut.height; y++) {
        if (y >= borderX0 && y < targetOut.height - borderX1)
            continue;
        for (int x = 0; x < targetOut.width; x++) {
            if (x >= borderX0 && x < targetOut.width - borderY1)
                continue;
            t.get(x, y, pixelT);
            v.get(x, y, pixelV);
            for (int band = 0; band < t.getNumberOfBands(); band++) {
                assertEquals(x + " " + y, pixelV[band], pixelT[band], 1e-4f);
            }
        }
    }
}
Also used : FactoryGImageMultiBand(boofcv.core.image.FactoryGImageMultiBand) GImageMultiBand(boofcv.core.image.GImageMultiBand) ImageInterleaved(boofcv.struct.image.ImageInterleaved)

Example 9 with ImageInterleaved

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

the class TestImageMiscOps method testAddUniform_Interleaved.

private void testAddUniform_Interleaved(Method m) throws InvocationTargetException, IllegalAccessException {
    Class[] paramTypes = m.getParameterTypes();
    ImageInterleaved orig = GeneralizedImageOps.createInterleaved(paramTypes[0], width, height, 2);
    GImageMiscOps.fill(orig, 1);
    if (orig.getDataType().isInteger()) {
        m.invoke(null, orig, rand, 1, 10);
    } else {
        m.invoke(null, orig, rand, 1, 10);
    }
    for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
            for (int band = 0; band < orig.numBands; band++) {
                double value = GeneralizedImageOps.get(orig, j, i, band);
                assertTrue(value >= -2 && value <= 11);
            }
        }
    }
}
Also used : ImageInterleaved(boofcv.struct.image.ImageInterleaved)

Example 10 with ImageInterleaved

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

the class TestImageMiscOps method testAddGaussian_Interleaved.

private void testAddGaussian_Interleaved(Method m) throws InvocationTargetException, IllegalAccessException {
    double mean = 10;
    Class[] paramTypes = m.getParameterTypes();
    ImageInterleaved orig = GeneralizedImageOps.createInterleaved(paramTypes[0], width, height, 2);
    GImageMiscOps.fill(orig, mean);
    m.invoke(null, orig, rand, 2.0, 0, 255);
    double stdev2 = 0;
    for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
            for (int band = 0; band < orig.numBands; band++) {
                double value = GeneralizedImageOps.get(orig, j, i, band);
                stdev2 += (value - mean) * (value - mean);
            }
        }
    }
    GImageMiscOps.fill(orig, mean);
    m.invoke(null, orig, rand, 10.0, 0, 255);
    double stdev10 = 0;
    for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
            for (int band = 0; band < orig.numBands; band++) {
                double value = GeneralizedImageOps.get(orig, j, i, band);
                stdev10 += (value - mean) * (value - mean);
            }
        }
    }
    // see if the gaussian with the larger variance creates a noisier image
    assertTrue(stdev2 < stdev10);
}
Also used : ImageInterleaved(boofcv.struct.image.ImageInterleaved)

Aggregations

ImageInterleaved (boofcv.struct.image.ImageInterleaved)12 FactoryGImageGray (boofcv.core.image.FactoryGImageGray)1 FactoryGImageMultiBand (boofcv.core.image.FactoryGImageMultiBand)1 GImageGray (boofcv.core.image.GImageGray)1 GImageMultiBand (boofcv.core.image.GImageMultiBand)1 KernelBase (boofcv.struct.convolve.KernelBase)1 ImageGray (boofcv.struct.image.ImageGray)1