Search in sources :

Example 16 with GImageGray

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));
}
Also used : FactoryGImageGray(boofcv.core.image.FactoryGImageGray) GImageGray(boofcv.core.image.GImageGray) Test(org.junit.Test)

Example 17 with GImageGray

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);
}
Also used : FactoryGImageGray(boofcv.core.image.FactoryGImageGray) GImageGray(boofcv.core.image.GImageGray) FactoryGImageGray(boofcv.core.image.FactoryGImageGray) GImageGray(boofcv.core.image.GImageGray) Test(org.junit.Test)

Example 18 with GImageGray

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);
}
Also used : GImageGray(boofcv.core.image.GImageGray) FactoryGImageGray(boofcv.core.image.FactoryGImageGray)

Example 19 with GImageGray

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);
}
Also used : GImageGray(boofcv.core.image.GImageGray) FactoryGImageGray(boofcv.core.image.FactoryGImageGray)

Example 20 with GImageGray

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));
    }
}
Also used : TupleDesc_B(boofcv.struct.feature.TupleDesc_B) GrayF32(boofcv.struct.image.GrayF32) GImageGray(boofcv.core.image.GImageGray) FactoryGImageGray(boofcv.core.image.FactoryGImageGray) Point2D_I32(georegression.struct.point.Point2D_I32) Test(org.junit.Test)

Aggregations

FactoryGImageGray (boofcv.core.image.FactoryGImageGray)35 GImageGray (boofcv.core.image.GImageGray)35 ImageGray (boofcv.struct.image.ImageGray)17 Test (org.junit.Test)5 Bitmap (android.graphics.Bitmap)3 TupleDesc_B (boofcv.struct.feature.TupleDesc_B)2 Point2D_I32 (georegression.struct.point.Point2D_I32)2 IntegralKernel (boofcv.alg.transform.ii.IntegralKernel)1 ImageRectangle (boofcv.struct.ImageRectangle)1 GrayF32 (boofcv.struct.image.GrayF32)1 GrayU8 (boofcv.struct.image.GrayU8)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1