Search in sources :

Example 1 with ImageBase

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

the class CompareToStandardConvolution method createInputParam.

@Override
protected Object[][] createInputParam(Method candidate, Method validation) {
    Class<?>[] paramTypes = candidate.getParameterTypes();
    ImageBase src = ConvolutionTestHelper.createImage(paramTypes[1], width, height);
    GImageMiscOps.fillUniform(src, rand, 0, 130);
    ImageBase dst = ConvolutionTestHelper.createImage(paramTypes[2], width, height);
    if (candidate.getName().compareTo("convolve") != 0) {
        Object[][] ret = new Object[1][paramTypes.length];
        ret[0][0] = createKernel(paramTypes[0]);
        ret[0][1] = src;
        ret[0][2] = dst;
        if (paramTypes.length == 4) {
            ret[0][3] = 11;
        }
        return ret;
    } else {
        Object[][] ret = new Object[1][paramTypes.length];
        ret[0][0] = createKernel(paramTypes[0]);
        ret[0][1] = src;
        ret[0][2] = dst;
        if (paramTypes.length == 4) {
            ret[0][3] = 11;
        }
        return ret;
    }
}
Also used : ImageBase(boofcv.struct.image.ImageBase)

Example 2 with ImageBase

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

the class TestConvolveImage method compareResults.

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

Example 3 with ImageBase

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

the class TestClipAndReduce method clipInput.

public void clipInput(ImageType type, int inW, int inH, int outW, int outH) {
    ImageBase input = type.createImage(inW, inH);
    GImageMiscOps.fillUniform(input, rand, -1, 1);
    ClipAndReduce alg = new ClipAndReduce(true, type);
    ImageBase output = type.createImage(outW, outH);
    GImageMiscOps.fillUniform(output, rand, -1, 1);
    ImageBase found = alg.clipInput(input, output);
    double foundAspect = found.width / (double) found.height;
    double expectedAspect = output.width / (double) output.height;
    // won't be perfect
    assertEquals(expectedAspect, foundAspect, 0.05);
}
Also used : ImageBase(boofcv.struct.image.ImageBase)

Example 4 with ImageBase

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

the class TestImageStatistics method testMeanDiffSq.

private void testMeanDiffSq(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, 19);
        GImageMiscOps.fillUniform(inputB, rand, -20, 19);
    } else {
        GImageMiscOps.fillUniform(inputA, rand, 0, 19);
        GImageMiscOps.fillUniform(inputB, rand, 0, 19);
    }
    Object result = m.invoke(null, inputA, inputB);
    double total = 0;
    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);
                total += (a - b) * (a - b);
            }
        }
    }
    double expected = total / (width * height * numBands);
    assertEquals(expected, ((Number) result).doubleValue(), 1e-4);
}
Also used : ImageBase(boofcv.struct.image.ImageBase)

Example 5 with ImageBase

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

the class TestImageStatistics method testMean.

private void testMean(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);
            }
        }
    }
    expected /= (width * height * numBands);
    double found = ((Number) result).doubleValue();
    assertEquals(expected, found, 1e-3);
}
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