Search in sources :

Example 56 with Planar

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

the class TestGPixelMath method divide_planar_by_gray_3.

@Test
public void divide_planar_by_gray_3() {
    Planar<GrayF32> numerator = new Planar<>(GrayF32.class, width, height, 2);
    GrayF32 denominator = new GrayF32(width, height);
    GImageMiscOps.fillUniform(numerator, rand, -10, 10);
    GImageMiscOps.fillUniform(denominator, rand, 1, 2);
    Planar<GrayF32> output = new Planar<>(GrayF32.class, width, height, 2);
    GPixelMath.divide(numerator, denominator, output);
    GrayF32 expected = denominator.createSameShape();
    for (int i = 0; i < numerator.getNumBands(); i++) {
        GPixelMath.divide(numerator.getBand(i), denominator, expected);
        BoofTesting.assertEquals(output.getBand(i), expected, 1e-4);
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32) Planar(boofcv.struct.image.Planar) Test(org.junit.Test)

Example 57 with Planar

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

the class TestGPixelMath method multiply_planar_by_gray_3.

@Test
public void multiply_planar_by_gray_3() {
    Planar<GrayF32> numerator = new Planar<>(GrayF32.class, width, height, 2);
    GrayF32 denominator = new GrayF32(width, height);
    GImageMiscOps.fillUniform(numerator, rand, -10, 10);
    GImageMiscOps.fillUniform(denominator, rand, 1, 2);
    Planar<GrayF32> output = new Planar<>(GrayF32.class, width, height, 2);
    GPixelMath.multiply(numerator, denominator, output);
    GrayF32 expected = denominator.createSameShape();
    for (int i = 0; i < numerator.getNumBands(); i++) {
        GPixelMath.multiply(numerator.getBand(i), denominator, expected);
        BoofTesting.assertEquals(output.getBand(i), expected, 1e-4);
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32) Planar(boofcv.struct.image.Planar) Test(org.junit.Test)

Example 58 with Planar

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

the class TestLikelihoodHistCoupled_PL_U8 method numBins.

@Test
public void numBins() {
    LikelihoodHistCoupled_PL_U8 alg = new LikelihoodHistCoupled_PL_U8(255, 30);
    Planar<GrayU8> image = new Planar<>(GrayU8.class, 30, 40, 3);
    // make sure the upper limit is handled correctly
    setColor(image, 5, 6, 255, 255, 255);
    alg.setImage(image);
    alg.createModel(new RectangleLength2D_I32(5, 6, 1, 1));
    assertEquals(30 * 30 * 30, alg.hist.length);
    assertEquals(1f, alg.hist[alg.hist.length - 1], 1e-4);
}
Also used : RectangleLength2D_I32(georegression.struct.shapes.RectangleLength2D_I32) Planar(boofcv.struct.image.Planar) GrayU8(boofcv.struct.image.GrayU8) Test(org.junit.Test)

Example 59 with Planar

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

the class TestLikelihoodHueSatHistCoupled_PL_U8 method multipleColors.

@Test
public void multipleColors() {
    LikelihoodHueSatHistCoupled_PL_U8 alg = new LikelihoodHueSatHistCoupled_PL_U8(255, 5);
    Planar<GrayU8> image = new Planar<>(GrayU8.class, 30, 40, 3);
    RectangleLength2D_I32 r0 = new RectangleLength2D_I32(3, 4, 8, 8);
    RectangleLength2D_I32 r1 = new RectangleLength2D_I32(11, 4, 4, 8);
    setColor(image, r0, 100, 105, 12);
    setColor(image, r1, 50, 200, 50);
    RectangleLength2D_I32 region = new RectangleLength2D_I32(3, 4, 12, 8);
    alg.setImage(image);
    alg.createModel(region);
    float v0 = alg.compute(3, 4);
    float v1 = alg.compute(11, 4);
    assertEquals(1.0f, v0 + v1, 1e-4);
    assertTrue(v0 > v1);
}
Also used : RectangleLength2D_I32(georegression.struct.shapes.RectangleLength2D_I32) Planar(boofcv.struct.image.Planar) GrayU8(boofcv.struct.image.GrayU8) Test(org.junit.Test)

Example 60 with Planar

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

the class TestLikelihoodHueSatHistInd_PL_U8 method numBins.

@Test
public void numBins() {
    LikelihoodHueSatHistInd_PL_U8 alg = new LikelihoodHueSatHistInd_PL_U8(255, 30);
    Planar<GrayU8> image = new Planar<>(GrayU8.class, 30, 40, 3);
    // make sure the upper limit is handled correctly
    setColor(image, 5, 6, 255, 255, 255);
    alg.setImage(image);
    alg.createModel(new RectangleLength2D_I32(5, 6, 1, 1));
    assertEquals(30, alg.binsH.length);
    assertEquals(30, alg.binsS.length);
    // it comes out to a slightly larger size on purpose
    assertEquals(2 * Math.PI, alg.sizeH * 30, 0.01);
    assertEquals(1.0, alg.sizeS * 30, 0.01);
}
Also used : RectangleLength2D_I32(georegression.struct.shapes.RectangleLength2D_I32) Planar(boofcv.struct.image.Planar) GrayU8(boofcv.struct.image.GrayU8) Test(org.junit.Test)

Aggregations

Planar (boofcv.struct.image.Planar)73 Test (org.junit.Test)39 GrayF32 (boofcv.struct.image.GrayF32)34 GrayU8 (boofcv.struct.image.GrayU8)28 BufferedImage (java.awt.image.BufferedImage)21 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)20 RectangleLength2D_I32 (georegression.struct.shapes.RectangleLength2D_I32)12 File (java.io.File)9 Bitmap (android.graphics.Bitmap)4 ListDisplayPanel (boofcv.gui.ListDisplayPanel)4 ImageGray (boofcv.struct.image.ImageGray)4 ConfigGeneralDetector (boofcv.abst.feature.detect.interest.ConfigGeneralDetector)3 LensDistortionUniversalOmni (boofcv.alg.distort.universal.LensDistortionUniversalOmni)3 MediaManager (boofcv.io.MediaManager)3 DefaultMediaManager (boofcv.io.wrapper.DefaultMediaManager)3 CameraPinhole (boofcv.struct.calib.CameraPinhole)3 GrayU16 (boofcv.struct.image.GrayU16)3 Homography2D_F64 (georegression.struct.homography.Homography2D_F64)3 Se3_F64 (georegression.struct.se.Se3_F64)3 DescribeRegionPoint (boofcv.abst.feature.describe.DescribeRegionPoint)2