use of boofcv.struct.image.ImageGray in project BoofCV by lessthanoptimal.
the class TestImplGrayImageOps method invert.
public void invert(Method m) throws InvocationTargetException, IllegalAccessException {
Class[] param = m.getParameterTypes();
ImageGray input = GeneralizedImageOps.createSingleBand(param[0], width, height);
GImageMiscOps.fillUniform(input, rand, 0, 100);
ImageGray output = GeneralizedImageOps.createSingleBand(param[0], width, height);
m.invoke(null, input, 255, output);
GImageGray a = FactoryGImageGray.wrap(input);
GImageGray b = FactoryGImageGray.wrap(output);
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
assertEquals(255 - a.get(x, y).doubleValue(), b.get(x, y).doubleValue(), 1e-4f);
}
}
}
use of boofcv.struct.image.ImageGray in project BoofCV by lessthanoptimal.
the class GenericWaveletDenoiseTests method denoiseImage.
@Override
public void denoiseImage(T imageNoisy, T imageDenoised) {
ImageGray transformedImg = transform.transform(imageNoisy, null);
// so this condition is also tested
if (imageNoisy.isSubimage()) {
transformedImg = (T) BoofTesting.createSubImageOf(transformedImg);
}
denoiseWavelet(transformedImg, transform.getLevels());
transform.invert(transformedImg, imageDenoised);
}
use of boofcv.struct.image.ImageGray in project BoofCV by lessthanoptimal.
the class TestImageMiscOps method testCopy.
private void testCopy(Method m) throws InvocationTargetException, IllegalAccessException {
Class[] paramTypes = m.getParameterTypes();
ImageGray src = GeneralizedImageOps.createSingleBand(paramTypes[6], width, height);
ImageGray dst = GeneralizedImageOps.createSingleBand(paramTypes[7], width, height);
GImageMiscOps.fillUniform(src, rand, 0, 20);
GImageMiscOps.fillUniform(dst, rand, 0, 20);
int w = 5, h = 8;
int x0 = 1, y0 = 2;
int x1 = 3, y1 = 4;
m.invoke(null, 1, 2, 3, 4, w, h, src, dst);
GImageGray a = FactoryGImageGray.wrap(src);
GImageGray b = FactoryGImageGray.wrap(dst);
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
assertEquals(a.get(x0 + j, y0 + i).doubleValue(), b.get(x1 + j, y1 + i).doubleValue(), 1e-4);
}
}
}
use of boofcv.struct.image.ImageGray in project BoofCV by lessthanoptimal.
the class TestImageMiscOps method testFlipVertical.
private void testFlipVertical(Method m, int height) throws IllegalAccessException, InvocationTargetException {
Class[] paramTypes = m.getParameterTypes();
ImageGray imgA = GeneralizedImageOps.createSingleBand(paramTypes[0], width, height);
GImageMiscOps.fillUniform(imgA, rand, 0, 100);
ImageGray imgB = (ImageGray) imgA.clone();
m.invoke(null, imgB);
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
double valA = GeneralizedImageOps.get(imgA, x, height - y - 1);
double valB = GeneralizedImageOps.get(imgB, x, y);
assertTrue(valA == valB);
}
}
}
use of boofcv.struct.image.ImageGray in project BoofCV by lessthanoptimal.
the class TestImageMiscOps method testFillRectangle_Single.
private void testFillRectangle_Single(Method m) throws InvocationTargetException, IllegalAccessException {
Class[] paramTypes = m.getParameterTypes();
ImageGray orig = GeneralizedImageOps.createSingleBand(paramTypes[0], width, height);
int x0 = 2;
int y0 = 3;
int width = 5;
int height = 6;
if (orig.getDataType().isInteger()) {
m.invoke(null, orig, 10, x0, y0, width, height);
} else {
m.invoke(null, orig, 10.0f, x0, y0, width, height);
}
GImageGray a = FactoryGImageGray.wrap(orig);
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
if (j < x0 || i < y0 || i >= (x0 + width) || j >= (y0 + height))
assertEquals(j + " " + i, 0.0, a.get(j, i).doubleValue(), 1e-4);
else
assertEquals(10.0, a.get(j, i).doubleValue(), 1e-4);
}
}
}
Aggregations