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);
}
}
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);
}
}
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 };
}
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;
}
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 };
}
Aggregations