Search in sources :

Example 81 with ImageGray

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

the class TestImplConvertBitmap method checkArrayToGray.

public void checkArrayToGray(Method m, Bitmap.Config config) {
    Bitmap orig = Bitmap.createBitmap(w, h, config);
    orig.setPixel(1, 2, 0xFF204010);
    Class[] params = m.getParameterTypes();
    try {
        ImageGray found = (ImageGray) params[2].getConstructor(int.class, int.class).newInstance(w, h);
        Object array;
        String info = params[2].getSimpleName();
        if (params[0] == int[].class) {
            info += " Array32";
            orig.copyPixelsToBuffer(IntBuffer.wrap(buffer32));
            array = buffer32;
        } else {
            info += " Array8";
            orig.copyPixelsToBuffer(ByteBuffer.wrap(buffer8));
            array = buffer8;
        }
        info += " " + config;
        m.invoke(null, array, config, found);
        GImageGray g = FactoryGImageGray.wrap(found);
        // should be 37 for both 8888 and 565
        assertEquals(info, 37, g.get(1, 2).intValue());
        assertEquals(info, 0, g.get(0, 0).intValue());
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : Bitmap(android.graphics.Bitmap) GImageGray(boofcv.core.image.GImageGray) FactoryGImageGray(boofcv.core.image.FactoryGImageGray) GImageGray(boofcv.core.image.GImageGray) FactoryGImageGray(boofcv.core.image.FactoryGImageGray) ImageGray(boofcv.struct.image.ImageGray)

Example 82 with ImageGray

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

the class TestImplConvertBitmap method checkBitmapToGrayRGB.

public void checkBitmapToGrayRGB(Method m, Bitmap.Config config) {
    Bitmap orig = Bitmap.createBitmap(w, h, config);
    orig.setPixel(1, 2, 0xFF204010);
    Class[] params = m.getParameterTypes();
    String info = config + " " + params[1].getSimpleName();
    try {
        ImageGray found = (ImageGray) params[1].getConstructor(int.class, int.class).newInstance(w, h);
        m.invoke(null, orig, found);
        GImageGray g = FactoryGImageGray.wrap(found);
        // should be 37 for both 8888 and 565
        assertEquals(info, 37, g.get(1, 2).intValue());
        assertEquals(info, 0, g.get(0, 0).intValue());
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : Bitmap(android.graphics.Bitmap) GImageGray(boofcv.core.image.GImageGray) FactoryGImageGray(boofcv.core.image.FactoryGImageGray) GImageGray(boofcv.core.image.GImageGray) FactoryGImageGray(boofcv.core.image.FactoryGImageGray) ImageGray(boofcv.struct.image.ImageGray)

Example 83 with ImageGray

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

the class TestImplConvolveBox method reformatForValidation.

@Override
protected Object[] reformatForValidation(Method m, Object[] targetParam) {
    Class<?>[] params = m.getParameterTypes();
    Object kernel = TestConvolveImageBox.createTableKernel(params[0], kernelRadius, rand);
    ImageGray output = (ImageGray) ((ImageGray) targetParam[1]).clone();
    return new Object[] { kernel, targetParam[0], output };
}
Also used : ImageGray(boofcv.struct.image.ImageGray)

Example 84 with ImageGray

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

the class TestImplConvolveMean method createInputParam.

@Override
protected Object[][] createInputParam(Method candidate, Method validation) {
    Class[] c = candidate.getParameterTypes();
    ImageGray input = GeneralizedImageOps.createSingleBand(c[0], width, height);
    ImageGray output = GeneralizedImageOps.createSingleBand(c[1], width, height);
    GImageMiscOps.fillUniform(input, rand, 0, 50);
    Object[][] ret = new Object[1][];
    ret[0] = new Object[] { input, output, kernelRadius };
    return ret;
}
Also used : ImageGray(boofcv.struct.image.ImageGray)

Example 85 with ImageGray

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

the class TestImplConvolveMean method reformatForValidation.

@Override
protected Object[] reformatForValidation(Method m, Object[] targetParam) {
    Class<?>[] params = m.getParameterTypes();
    Object kernel = createTableKernel(params[0], kernelRadius);
    ImageGray output = (ImageGray) ((ImageGray) targetParam[1]).clone();
    int w = kernelRadius * 2 + 1;
    if (output.getDataType().isInteger())
        return new Object[] { kernel, targetParam[0], output, w };
    else
        return new Object[] { kernel, targetParam[0], output };
}
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