Search in sources :

Example 76 with GrayS32

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

the class TestWatershedVincentSoille1991_Connect4 method example2.

@Test
public void example2() {
    GrayU8 image = new GrayU8(5, 4);
    image.data = new byte[] { 5, 5, 5, 5, 5, 5, 1, 5, 1, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 };
    WatershedVincentSoille1991 alg = new WatershedVincentSoille1991.Connect4();
    alg.process(image);
    GrayS32 found = alg.getOutput();
    assertEquals(3, alg.getTotalRegions());
    int a = found.get(0, 0);
    int b = found.get(4, 0);
    assertTrue(a > 0);
    assertTrue(b > 0);
    assertTrue(a != b);
    for (int y = 0; y < image.height; y++) {
        assertEquals(a, found.get(0, y));
        assertEquals(a, found.get(1, y));
        assertEquals(0, found.get(2, y));
        assertEquals(b, found.get(3, y));
        assertEquals(b, found.get(4, y));
    }
}
Also used : GrayU8(boofcv.struct.image.GrayU8) GrayS32(boofcv.struct.image.GrayS32) Test(org.junit.Test)

Example 77 with GrayS32

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

the class TestWatershedVincentSoille1991_Connect4 method exampleSeeds1.

@Test
public void exampleSeeds1() {
    GrayU8 image = new GrayU8(4, 4);
    image.data = new byte[] { 1, 5, 5, 1, 1, 5, 5, 1, 1, 5, 5, 1, 1, 5, 5, 1 };
    // seed from a value which isn't a local minimum
    GrayS32 seed = new GrayS32(4, 4);
    seed.data = new int[] { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    WatershedVincentSoille1991 alg = new WatershedVincentSoille1991.Connect4();
    alg.process(image, seed);
    GrayS32 found = alg.getOutput();
    // the whole thing should be filled with 1
    for (int y = 0; y < image.height; y++) {
        for (int x = 0; x < image.width; x++) {
            assertEquals(1, found.get(x, y));
        }
    }
}
Also used : GrayU8(boofcv.struct.image.GrayU8) GrayS32(boofcv.struct.image.GrayS32) Test(org.junit.Test)

Example 78 with GrayS32

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

the class TestWatershedVincentSoille1991_Connect8 method exampleSeeds1.

@Test
public void exampleSeeds1() {
    GrayU8 image = new GrayU8(4, 4);
    image.data = new byte[] { 1, 5, 5, 1, 1, 5, 5, 1, 1, 5, 5, 1, 1, 5, 5, 1 };
    // seed from a value which isn't a local minimum
    GrayS32 seed = new GrayS32(4, 4);
    seed.data = new int[] { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    WatershedVincentSoille1991 alg = new WatershedVincentSoille1991.Connect8();
    alg.process(image, seed);
    GrayS32 found = alg.getOutput();
    // the whole thing should be filled with 1
    for (int y = 0; y < image.height; y++) {
        for (int x = 0; x < image.width; x++) {
            assertEquals(1, found.get(x, y));
        }
    }
}
Also used : GrayU8(boofcv.struct.image.GrayU8) GrayS32(boofcv.struct.image.GrayS32) Test(org.junit.Test)

Example 79 with GrayS32

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

the class TestWatershedVincentSoille1991_Connect8 method exampleSeeds0.

@Test
public void exampleSeeds0() {
    GrayU8 image = new GrayU8(4, 4);
    image.data = new byte[] { 1, 5, 5, 1, 1, 5, 5, 1, 1, 5, 5, 1, 1, 5, 5, 1 };
    GrayS32 seed = new GrayS32(4, 4);
    seed.data = new int[] { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    WatershedVincentSoille1991 alg = new WatershedVincentSoille1991.Connect8();
    alg.process(image, seed);
    GrayS32 found = alg.getOutput();
    // the whole thing should be filled with 1
    for (int y = 0; y < image.height; y++) {
        for (int x = 0; x < image.width; x++) {
            assertEquals(1, found.get(x, y));
        }
    }
}
Also used : GrayU8(boofcv.struct.image.GrayU8) GrayS32(boofcv.struct.image.GrayS32) Test(org.junit.Test)

Example 80 with GrayS32

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

the class TestWatershedVincentSoille1991_Connect8 method example4.

@Test
public void example4() {
    GrayU8 image = new GrayU8(5, 4);
    image.data = new byte[] { 5, 5, 5, 5, 5, 5, 1, 4, 2, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 5 };
    WatershedVincentSoille1991 alg = new WatershedVincentSoille1991.Connect8();
    alg.process(image);
    GrayS32 found = alg.getOutput();
    // found.print();
    assertEquals(4, alg.getTotalRegions());
    int[] expected = new int[] { 1, 1, 0, 2, 2, 1, 1, 0, 2, 2, 1, 1, 0, 0, 0, 1, 0, 3, 3, 3 };
    int index = 0;
    for (int y = 0; y < image.height; y++) {
        for (int x = 0; x < image.width; x++) {
            assertEquals(expected[index++], found.get(x, y));
        }
    }
}
Also used : GrayU8(boofcv.struct.image.GrayU8) GrayS32(boofcv.struct.image.GrayS32) Test(org.junit.Test)

Aggregations

GrayS32 (boofcv.struct.image.GrayS32)102 Test (org.junit.Test)79 GrayU8 (boofcv.struct.image.GrayU8)52 GrayF32 (boofcv.struct.image.GrayF32)13 GrowQueue_I32 (org.ddogleg.struct.GrowQueue_I32)10 Point2D_I32 (georegression.struct.point.Point2D_I32)7 FactoryGImageGray (boofcv.core.image.FactoryGImageGray)4 GImageGray (boofcv.core.image.GImageGray)4 ImageGray (boofcv.struct.image.ImageGray)4 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)3 ImageDimension (boofcv.struct.image.ImageDimension)3 BufferedImage (java.awt.image.BufferedImage)3 FastQueue (org.ddogleg.struct.FastQueue)3 WatershedVincentSoille1991 (boofcv.alg.segmentation.watershed.WatershedVincentSoille1991)2 IntegralKernel (boofcv.alg.transform.ii.IntegralKernel)2 ImageBorder_S32 (boofcv.core.image.border.ImageBorder_S32)2 ListDisplayPanel (boofcv.gui.ListDisplayPanel)2 ImageRectangle (boofcv.struct.ImageRectangle)2 PackedSetsPoint2D_I32 (boofcv.struct.PackedSetsPoint2D_I32)2 Kernel2D_S32 (boofcv.struct.convolve.Kernel2D_S32)2