Search in sources :

Example 46 with GrayU8

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

the class TestInputSanityCheck method checkShape_three.

@Test
public void checkShape_three() {
    GrayU8 a = new GrayU8(imgWidth, imgHeight);
    GrayU8 b = new GrayU8(imgWidth, imgHeight);
    GrayU8 c = new GrayU8(imgWidth, imgHeight);
    // InputSanityCheck test
    InputSanityCheck.checkSameShape(a, b, c);
    // negative test
    try {
        b = new GrayU8(imgWidth + 1, imgHeight);
        InputSanityCheck.checkSameShape(a, b, c);
        fail("Didn't throw an exception");
    } catch (IllegalArgumentException e) {
    }
    try {
        b = new GrayU8(imgWidth, imgHeight + 1);
        InputSanityCheck.checkSameShape(a, b, c);
        fail("Didn't throw an exception");
    } catch (IllegalArgumentException e) {
    }
    b = new GrayU8(imgWidth, imgHeight);
    try {
        c = new GrayU8(imgWidth + 1, imgHeight);
        InputSanityCheck.checkSameShape(a, b, c);
        fail("Didn't throw an exception");
    } catch (IllegalArgumentException e) {
    }
    try {
        c = new GrayU8(imgWidth, imgHeight + 1);
        InputSanityCheck.checkSameShape(a, b, c);
        fail("Didn't throw an exception");
    } catch (IllegalArgumentException e) {
    }
}
Also used : GrayU8(boofcv.struct.image.GrayU8) Test(org.junit.Test)

Example 47 with GrayU8

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

the class TestInputSanityCheck method checkShape_two.

@Test
public void checkShape_two() {
    GrayU8 a = new GrayU8(imgWidth, imgHeight);
    GrayU8 b = new GrayU8(imgWidth, imgHeight);
    // InputSanityCheck test
    InputSanityCheck.checkSameShape(a, b);
    // negative test
    try {
        b = new GrayU8(imgWidth + 1, imgHeight);
        InputSanityCheck.checkSameShape(a, b);
        fail("Didn't throw an exception");
    } catch (IllegalArgumentException e) {
    }
    try {
        b = new GrayU8(imgWidth, imgHeight + 1);
        InputSanityCheck.checkSameShape(a, b);
        fail("Didn't throw an exception");
    } catch (IllegalArgumentException e) {
    }
}
Also used : GrayU8(boofcv.struct.image.GrayU8) Test(org.junit.Test)

Example 48 with GrayU8

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

the class DetectLineHoughFootSubimage method processSubimage.

private void processSubimage(int x0, int y0, int x1, int y1, List<LineParametric2D_F32> found) {
    D derivX = (D) this.derivX.subimage(x0, y0, x1, y1);
    D derivY = (D) this.derivY.subimage(x0, y0, x1, y1);
    GrayU8 binary = this.binary.subimage(x0, y0, x1, y1);
    alg.transform(derivX, derivY, binary);
    FastQueue<LineParametric2D_F32> lines = alg.extractLines();
    float[] intensity = alg.getFoundIntensity();
    for (int i = 0; i < lines.size; i++) {
        // convert from the sub-image coordinate system to original image coordinate system
        LineParametric2D_F32 l = lines.get(i).copy();
        l.p.x += x0;
        l.p.y += y0;
        found.add(l);
        post.add(l, intensity[i]);
    }
}
Also used : GrayU8(boofcv.struct.image.GrayU8) LineParametric2D_F32(georegression.struct.line.LineParametric2D_F32)

Example 49 with GrayU8

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

the class FhEdgeWeights4_PLU8 method check.

private void check(int x, int y, int[] color0, int indexA, Planar<GrayU8> input, FastQueue<Edge> edges) {
    if (!input.isInBounds(x, y))
        return;
    int indexSrc = input.startIndex + y * input.stride + x;
    int indexB = +y * input.width + x;
    float weight = 0;
    for (int i = 0; i < numBands; i++) {
        GrayU8 band = input.getBand(i);
        int color = band.data[indexSrc] & 0xFF;
        int diff = color0[i] - color;
        weight += diff * diff;
    }
    Edge e1 = edges.grow();
    e1.sortValue = (float) Math.sqrt(weight);
    e1.indexA = indexA;
    e1.indexB = indexB;
}
Also used : GrayU8(boofcv.struct.image.GrayU8) Edge(boofcv.alg.segmentation.fh04.SegmentFelzenszwalbHuttenlocher04.Edge)

Example 50 with GrayU8

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

the class FhEdgeWeights8_PLU8 method checkAround.

private void checkAround(int x, int y, Planar<GrayU8> input, FastQueue<Edge> edges) {
    int indexSrc = input.startIndex + y * input.stride + x;
    int indexA = y * input.width + x;
    for (int i = 0; i < numBands; i++) {
        GrayU8 band = input.getBand(i);
        pixelColor[i] = band.data[indexSrc] & 0xFF;
    }
    check(x + 1, y, pixelColor, indexA, input, edges);
    check(x, y + 1, pixelColor, indexA, input, edges);
    check(x + 1, y + 1, pixelColor, indexA, input, edges);
    check(x - 1, y + 1, pixelColor, indexA, input, edges);
}
Also used : GrayU8(boofcv.struct.image.GrayU8)

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