Search in sources :

Example 11 with GrayU8

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

the class TestBinaryImageOps method labelToBinary_individual_indexes.

@Test
public void labelToBinary_individual_indexes() {
    GrayU8 expected = new GrayU8(13, 8);
    expected.data = TEST;
    GrayU8 found = new GrayU8(13, 8);
    GrayS32 input = new GrayS32(13, 8);
    input.data = EXPECTED8;
    BinaryImageOps.labelToBinary(input, found, 3, 2);
    for (int i = 0; i < 8; i++) {
        for (int j = 0; j < 13; j++) {
            if (input.get(j, i) == 2) {
                assertEquals(1, found.get(j, i));
            } else {
                assertEquals(0, found.get(j, i));
            }
        }
    }
}
Also used : GrayU8(boofcv.struct.image.GrayU8) GrayS32(boofcv.struct.image.GrayS32) Test(org.junit.Test)

Example 12 with GrayU8

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

the class TestBinaryImageOps method labelToBinary.

@Test
public void labelToBinary() {
    GrayU8 expected = new GrayU8(13, 8);
    expected.data = TEST;
    GrayU8 found = new GrayU8(13, 8);
    GrayS32 input = new GrayS32(13, 8);
    input.data = EXPECTED8;
    BinaryImageOps.labelToBinary(input, found);
    BoofTesting.assertEquals(expected, found, 0);
}
Also used : GrayU8(boofcv.struct.image.GrayU8) GrayS32(boofcv.struct.image.GrayS32) Test(org.junit.Test)

Example 13 with GrayU8

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

the class TestBinaryImageOps method contour.

/**
 * Very crude and not exhaustive check of contour
 */
@Test
public void contour() {
    GrayU8 input = new GrayU8(10, 12);
    ImageMiscOps.fillRectangle(input, 1, 2, 3, 4, 5);
    input.set(9, 11, 1);
    GrayS32 output = new GrayS32(10, 12);
    GrayS32 expected = new GrayS32(10, 12);
    ImageMiscOps.fillRectangle(expected, 1, 2, 3, 4, 5);
    expected.set(9, 11, 2);
    List<Contour> found = BinaryImageOps.contour(input, ConnectRule.FOUR, output);
    assertEquals(2, found.size());
    BoofTesting.assertEquals(expected, output, 0);
}
Also used : GrayU8(boofcv.struct.image.GrayU8) GrayS32(boofcv.struct.image.GrayS32) Test(org.junit.Test)

Example 14 with GrayU8

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

the class TestBinaryImageOps method logicXor.

@Test
public void logicXor() {
    GrayU8 image0 = new GrayU8(5, 6);
    GrayU8 image1 = new GrayU8(5, 6);
    image0.set(0, 0, 1);
    image0.set(1, 1, 1);
    image1.set(0, 0, 0);
    image1.set(1, 1, 1);
    GrayU8 out = BinaryImageOps.logicXor(image0, image1, null);
    assertEquals(1, out.get(0, 0));
    assertEquals(0, out.get(1, 1));
    assertEquals(0, out.get(0, 1));
}
Also used : GrayU8(boofcv.struct.image.GrayU8) Test(org.junit.Test)

Example 15 with GrayU8

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

the class TestContourTracer method two_horizontal.

@Test
public void two_horizontal() {
    GrayU8 pattern = new GrayU8(2, 1);
    ImageMiscOps.fill(pattern, 1);
    shiftContourCheck(pattern, 2, ConnectRule.FOUR);
    shiftContourCheck(pattern, 2, ConnectRule.EIGHT);
}
Also used : GrayU8(boofcv.struct.image.GrayU8) Test(org.junit.Test)

Aggregations

GrayU8 (boofcv.struct.image.GrayU8)417 Test (org.junit.Test)242 BufferedImage (java.awt.image.BufferedImage)53 GrayS32 (boofcv.struct.image.GrayS32)52 GrayF32 (boofcv.struct.image.GrayF32)49 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)48 GrayS16 (boofcv.struct.image.GrayS16)45 Planar (boofcv.struct.image.Planar)28 ArrayList (java.util.ArrayList)22 File (java.io.File)17 ListDisplayPanel (boofcv.gui.ListDisplayPanel)16 RectangleLength2D_I32 (georegression.struct.shapes.RectangleLength2D_I32)16 ImageGray (boofcv.struct.image.ImageGray)15 EllipseRotated_F64 (georegression.struct.curve.EllipseRotated_F64)15 Random (java.util.Random)14 Point2D_F64 (georegression.struct.point.Point2D_F64)11 ImageRectangle (boofcv.struct.ImageRectangle)10 GrayU16 (boofcv.struct.image.GrayU16)10 Se3_F64 (georegression.struct.se.Se3_F64)10 Point3D_F64 (georegression.struct.point.Point3D_F64)9