Search in sources :

Example 26 with GrayU8

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

the class TestLinearContourLabelChang2004 method test3_8.

@Test
public void test3_8() {
    GrayU8 input = TEST4.clone();
    GrayS32 labeled = new GrayS32(input.width, input.height);
    LinearContourLabelChang2004 alg = new LinearContourLabelChang2004(ConnectRule.EIGHT);
    alg.process(input, labeled);
    assertEquals(1, alg.getContours().size);
    checkContour(alg, labeled, 8);
}
Also used : GrayU8(boofcv.struct.image.GrayU8) GrayS32(boofcv.struct.image.GrayS32) Test(org.junit.Test)

Example 27 with GrayU8

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

the class TestLinearContourLabelChang2004 method test2_8.

@Test
public void test2_8() {
    GrayU8 input = TEST2.clone();
    GrayS32 labeled = new GrayS32(input.width, input.height);
    LinearContourLabelChang2004 alg = new LinearContourLabelChang2004(ConnectRule.EIGHT);
    alg.process(input, labeled);
    assertEquals(4, alg.getContours().size);
    checkContour(alg, labeled, 8);
}
Also used : GrayU8(boofcv.struct.image.GrayU8) GrayS32(boofcv.struct.image.GrayS32) Test(org.junit.Test)

Example 28 with GrayU8

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

the class TestThresholdImageOps method localGaussian.

@Test
public void localGaussian() {
    int total = 0;
    Method[] list = ThresholdImageOps.class.getMethods();
    for (Method m : list) {
        if (!m.getName().equals("localGaussian"))
            continue;
        Class[] param = m.getParameterTypes();
        ImageGray input = GeneralizedImageOps.createSingleBand(param[0], width, height);
        GrayU8 output = new GrayU8(width, height);
        GImageMiscOps.fillUniform(input, rand, 0, 200);
        BoofTesting.checkSubImage(this, "performLocalGaussian", true, m, input, output);
        total++;
    }
    assertEquals(2, total);
}
Also used : GImageGray(boofcv.core.image.GImageGray) FactoryGImageGray(boofcv.core.image.FactoryGImageGray) ImageGray(boofcv.struct.image.ImageGray) GrayU8(boofcv.struct.image.GrayU8) Method(java.lang.reflect.Method) Test(org.junit.Test)

Example 29 with GrayU8

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

the class TestThresholdImageOps method naiveLocalSquare.

public void naiveLocalSquare(ImageGray input, GrayU8 output, int radius, double scale, boolean down) {
    ImageGray blur;
    boolean isInt;
    if (input instanceof GrayU8) {
        isInt = true;
        blur = BlurImageOps.mean((GrayU8) input, null, radius, null);
    } else {
        isInt = false;
        blur = BlurImageOps.mean((GrayF32) input, null, radius, null);
    }
    float fscale = (float) scale;
    for (int y = 0; y < input.height; y++) {
        for (int x = 0; x < input.width; x++) {
            double threshold = GeneralizedImageOps.get(blur, x, y);
            double v = GeneralizedImageOps.get(input, x, y);
            boolean one;
            if (down) {
                if (isInt) {
                    one = (int) v <= ((int) threshold) * fscale;
                } else {
                    one = v <= threshold * fscale;
                }
            } else {
                if (isInt) {
                    one = ((int) v) * fscale > (int) threshold;
                } else {
                    one = v * fscale > threshold;
                }
            }
            if (one) {
                output.set(x, y, 1);
            } else {
                output.set(x, y, 0);
            }
        }
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32) GImageGray(boofcv.core.image.GImageGray) FactoryGImageGray(boofcv.core.image.FactoryGImageGray) ImageGray(boofcv.struct.image.ImageGray) GrayU8(boofcv.struct.image.GrayU8)

Example 30 with GrayU8

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

the class TestThresholdImageOps method threshold.

@Test
public void threshold() {
    int total = 0;
    Method[] list = ThresholdImageOps.class.getMethods();
    for (Method m : list) {
        if (!m.getName().equals("threshold"))
            continue;
        Class[] param = m.getParameterTypes();
        ImageGray input = GeneralizedImageOps.createSingleBand(param[0], width, height);
        GrayU8 output = new GrayU8(width, height);
        GImageGray a = FactoryGImageGray.wrap(input);
        for (int y = 0; y < input.height; y++) {
            for (int x = 0; x < input.width; x++) {
                a.set(x, y, x);
            }
        }
        BoofTesting.checkSubImage(this, "performThreshold", true, m, input, output);
        total++;
    }
    assertEquals(6, total);
}
Also used : GImageGray(boofcv.core.image.GImageGray) FactoryGImageGray(boofcv.core.image.FactoryGImageGray) GImageGray(boofcv.core.image.GImageGray) FactoryGImageGray(boofcv.core.image.FactoryGImageGray) ImageGray(boofcv.struct.image.ImageGray) GrayU8(boofcv.struct.image.GrayU8) Method(java.lang.reflect.Method) 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