use of boofcv.core.image.GImageGray in project BoofCV by lessthanoptimal.
the class StandardSingleBandTests method subimage.
@Test
public void subimage() {
T img = createImage(10, 20);
setRandom(img);
T sub = (T) img.subimage(2, 3, 3, 5, null);
assertTrue(img.getImageType() == sub.getImageType());
assertEquals(1, sub.getWidth());
assertEquals(2, sub.getHeight());
GImageGray a = FactoryGImageGray.wrap(img);
GImageGray b = FactoryGImageGray.wrap(sub);
assertEquals(a.get(2, 3), b.get(0, 0));
assertEquals(a.get(2, 4), b.get(0, 1));
}
use of boofcv.core.image.GImageGray in project BoofCV by lessthanoptimal.
the class StandardSingleBandTests method serialize.
@Test
public void serialize() throws IOException, ClassNotFoundException {
// randomly fill the image
ImageGray imgA = createImage(10, 20);
GImageGray a = FactoryGImageGray.wrap(imgA);
for (int i = 0; i < imgA.getHeight(); i++) {
for (int j = 0; j < imgA.getWidth(); j++) {
a.set(j, i, rand.nextDouble() * 200);
}
}
// make a copy of the original
ImageGray imgB = (ImageGray) imgA.clone();
ByteArrayOutputStream streamOut = new ByteArrayOutputStream(1000);
ObjectOutputStream out = new ObjectOutputStream(streamOut);
out.writeObject(imgA);
out.close();
ByteArrayInputStream streamIn = new ByteArrayInputStream(streamOut.toByteArray());
ObjectInputStream in = new ObjectInputStream(streamIn);
ImageGray found = (ImageGray) in.readObject();
// see if everything is equals
checkEquals(imgA, imgB);
checkEquals(imgA, found);
}
use of boofcv.core.image.GImageGray in project BoofCV by lessthanoptimal.
the class TestGradientToEdgeFeatures method intensityAbs.
public void intensityAbs(Method m, ImageGray derivX, ImageGray derivY, GrayF32 intensity) throws InvocationTargetException, IllegalAccessException {
m.invoke(null, derivX, derivY, intensity);
GImageGray a = FactoryGImageGray.wrap(derivX);
GImageGray b = FactoryGImageGray.wrap(derivY);
float expected = Math.abs(a.get(1, 2).floatValue()) + Math.abs(b.get(1, 2).floatValue());
assertEquals(expected, intensity.get(1, 2), 1e-4);
}
use of boofcv.core.image.GImageGray in project BoofCV by lessthanoptimal.
the class TestGradientToEdgeFeatures method intensityE.
public void intensityE(Method m, ImageGray derivX, ImageGray derivY, GrayF32 intensity) throws InvocationTargetException, IllegalAccessException {
m.invoke(null, derivX, derivY, intensity);
GImageGray a = FactoryGImageGray.wrap(derivX);
GImageGray b = FactoryGImageGray.wrap(derivY);
float expected = (float) Math.sqrt(Math.pow(a.get(1, 2).doubleValue(), 2) + Math.pow(b.get(1, 2).doubleValue(), 2));
assertEquals(expected, intensity.get(1, 2), 1e-4);
}
use of boofcv.core.image.GImageGray in project BoofCV by lessthanoptimal.
the class TestDescribePointBriefSO method testManualCheck.
/**
* Compute the BRIEF descriptor manually and see if it gets the same answer
*/
@Test
public void testManualCheck() {
GrayF32 input = createImage(width, height);
GrayF32 blurred = input.createNew(width, height);
filterBlur.process(input, blurred);
GImageGray a = FactoryGImageGray.wrap(blurred);
DescribePointBriefSO<GrayF32> alg = createAlg();
alg.setImage(input);
int c_x = input.width / 2;
int c_y = input.height / 2;
TupleDesc_B desc = alg.createFeature();
alg.process(c_x, c_y, 0, briefRadius, desc);
double s = briefRadius / BoofDefaults.BRIEF_SCALE_TO_RADIUS;
for (int i = 0; i < def.compare.length; i++) {
Point2D_I32 c = def.compare[i];
Point2D_I32 p0 = def.samplePoints[c.x];
Point2D_I32 p1 = def.samplePoints[c.y];
boolean expected = a.get((int) Math.round(c_x + p0.x * s), (int) Math.round(c_y + p0.y * s)).doubleValue() < a.get((int) Math.round(c_x + p1.x * s), (int) Math.round(c_y + p1.y * s)).doubleValue();
assertTrue(expected == desc.isBitTrue(i));
}
}
Aggregations