Search in sources :

Example 86 with GrayS32

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

the class TestImageSegmentationOps method regionPixelId_to_Compact.

/**
 * Manually construct input data and see if it has the expected output
 */
@Test
public void regionPixelId_to_Compact() {
    GrayS32 graph = new GrayS32(4, 5);
    GrayS32 output = new GrayS32(4, 5);
    regionPixelId_to_Compact(graph, output);
    regionPixelId_to_Compact(BoofTesting.createSubImageOf(graph), output);
    regionPixelId_to_Compact(graph, BoofTesting.createSubImageOf(output));
}
Also used : GrayS32(boofcv.struct.image.GrayS32) Test(org.junit.Test)

Example 87 with GrayS32

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

the class TestSegmentFelzenszwalbHuttenlocher04 method mergeRegions.

@Test
public void mergeRegions() {
    // K is zero to make it easier to figure out if two edges should be merged or not
    SegmentFelzenszwalbHuttenlocher04 alg = new SegmentFelzenszwalbHuttenlocher04(0, 10, null);
    // add edges.  Design it such that order is important and to make sure the equality checks
    // are done correctly
    alg.edges.add(edge(1, 0, 20));
    alg.edges.add(edge(2, 0, 25));
    alg.edges.add(edge(14, 0, 40));
    alg.edges.add(edge(3, 4, 20));
    alg.edges.add(edge(5, 4, 20));
    alg.edges.add(edge(10, 11, 20));
    alg.edges.add(edge(12, 11, 5));
    alg.edges.add(edge(13, 11, 5));
    // randomize their order
    Collections.shuffle(alg.edges.toList(), rand);
    // NOTE the order after sorting is undefined.  So the checks below could be incorrect if they are processed
    // in a different order
    alg.graph = new GrayS32(4, 5);
    alg.graph.data = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 };
    alg.regionSize.reset();
    alg.threshold.reset();
    for (int i = 0; i < 20; i++) {
        alg.regionSize.add(i);
        // high value so that all first matches are accepted
        alg.threshold.add(1000);
    }
    // make sure that the regions are merged correctly
    alg.mergeRegions();
    // check the graph
    assertEquals(1, alg.graph.data[0]);
    assertEquals(1, alg.graph.data[1]);
    assertEquals(2, alg.graph.data[2]);
    assertEquals(5, alg.graph.data[3]);
    assertEquals(5, alg.graph.data[4]);
    assertEquals(5, alg.graph.data[5]);
    assertEquals(10, alg.graph.data[10]);
    assertEquals(13, alg.graph.data[11]);
    assertEquals(13, alg.graph.data[12]);
    assertEquals(13, alg.graph.data[13]);
    assertEquals(14, alg.graph.data[14]);
    // see if thresholds were updated as expected
    assertEquals(20, alg.threshold.data[1], 1e-4f);
    assertEquals(20, alg.threshold.data[5], 1e-4f);
    assertEquals(1000, alg.threshold.data[10], 1e-4f);
    assertEquals(5, alg.threshold.data[13], 1e-4f);
    assertEquals(1000, alg.threshold.data[14], 1e-4f);
    // ditto for size
    assertEquals(1, alg.regionSize.data[1]);
    assertEquals(2, alg.regionSize.data[2]);
    assertEquals(12, alg.regionSize.data[5]);
    assertEquals(10, alg.regionSize.data[10]);
    assertEquals(11 + 12 + 13, alg.regionSize.data[13]);
    assertEquals(14, alg.regionSize.data[14]);
}
Also used : GrayS32(boofcv.struct.image.GrayS32) Test(org.junit.Test)

Example 88 with GrayS32

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

the class DerivativeHelperFunctions method processBorderHorizontal.

public static void processBorderHorizontal(GrayU8 orig, GrayS32 deriv, Kernel1D_S32 kernel, ImageBorder_S32 borderType) {
    borderType.setImage(orig);
    ConvolveJustBorder_General_SB.horizontal(kernel, borderType, deriv);
    GrayU8 origSub;
    GrayS32 derivSub;
    origSub = orig.subimage(0, 0, orig.width, 2, null);
    derivSub = deriv.subimage(0, 0, orig.width, 2, null);
    ConvolveImageNoBorder.horizontal(kernel, origSub, derivSub);
    origSub = orig.subimage(0, orig.height - 2, orig.width, orig.height, null);
    derivSub = deriv.subimage(0, orig.height - 2, orig.width, orig.height, null);
    ConvolveImageNoBorder.horizontal(kernel, origSub, derivSub);
}
Also used : GrayU8(boofcv.struct.image.GrayU8) GrayS32(boofcv.struct.image.GrayS32)

Example 89 with GrayS32

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

the class TestGradientThree_Standard method compareToConvolve_I8_S32.

@Test
public void compareToConvolve_I8_S32() throws NoSuchMethodException {
    CompareDerivativeToConvolution validator = new CompareDerivativeToConvolution();
    validator.setTarget(GradientThree_Standard.class.getMethod("process", GrayU8.class, GrayS32.class, GrayS32.class));
    validator.setKernel(0, GradientThree.kernelDeriv_I32, true);
    validator.setKernel(1, GradientThree.kernelDeriv_I32, false);
    GrayU8 input = new GrayU8(width, height);
    ImageMiscOps.fillUniform(input, rand, 0, 10);
    GrayS32 derivX = new GrayS32(width, height);
    GrayS32 derivY = new GrayS32(width, height);
    validator.compare(false, input, derivX, derivY);
}
Also used : CompareDerivativeToConvolution(boofcv.alg.filter.derivative.CompareDerivativeToConvolution) GrayU8(boofcv.struct.image.GrayU8) GrayS32(boofcv.struct.image.GrayS32) Test(org.junit.Test)

Example 90 with GrayS32

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

the class TestKernelMath method convertToKernel_I32.

@Test
public void convertToKernel_I32() {
    GrayS32 image = new GrayS32(7, 7);
    ImageMiscOps.fillUniform(image, rand, -10, 10);
    Kernel2D_S32 kernel = KernelMath.convertToKernel(image);
    assertEquals(kernel.width, image.width);
    assertEquals(kernel.width, image.height);
    for (int i = 0; i < kernel.width; i++) {
        for (int j = 0; j < kernel.width; j++) {
            assertEquals(image.get(j, i), kernel.get(j, i), 1e-4);
        }
    }
}
Also used : 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