Search in sources :

Example 26 with Planar

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

the class TestLikelihoodHueSatHistCoupled_PL_U8 method singleColor.

@Test
public void singleColor() {
    LikelihoodHueSatHistCoupled_PL_U8 alg = new LikelihoodHueSatHistCoupled_PL_U8(255, 5);
    Planar<GrayU8> image = new Planar<>(GrayU8.class, 30, 40, 3);
    RectangleLength2D_I32 r = new RectangleLength2D_I32(3, 4, 12, 8);
    setColor(image, r, 100, 105, 12);
    alg.setImage(image);
    alg.createModel(r);
    assertEquals(1.0f, alg.compute(3, 4), 1e-4);
    assertEquals(1.0f, alg.compute(14, 11), 1e-4);
    assertEquals(0, alg.compute(10, 30), 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 27 with Planar

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

the class TestLikelihoodHueSatHistInd_PL_U8 method convertToHueSat.

@Test
public void convertToHueSat() {
    LikelihoodHueSatHistInd_PL_U8 alg = new LikelihoodHueSatHistInd_PL_U8(255, 30);
    Planar<GrayU8> image = new Planar<>(GrayU8.class, 30, 40, 3);
    setColor(image, 5, 6, 120, 50, 255);
    alg.setImage(image);
    alg.createModel(new RectangleLength2D_I32(5, 6, 1, 1));
    float[] hsv = new float[3];
    ColorHsv.rgbToHsv(120, 50, 255, hsv);
    int indexH = (int) (hsv[0] / alg.sizeH);
    int indexS = (int) (hsv[1] / alg.sizeS);
    assertEquals(1.0, alg.binsH[indexH], 1e-4);
    assertEquals(1.0, alg.binsS[indexS], 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 28 with Planar

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

the class TestLikelihoodHueSatHistInd_PL_U8 method singleColor.

@Test
public void singleColor() {
    LikelihoodHueSatHistInd_PL_U8 alg = new LikelihoodHueSatHistInd_PL_U8(255, 5);
    Planar<GrayU8> image = new Planar<>(GrayU8.class, 30, 40, 3);
    RectangleLength2D_I32 r = new RectangleLength2D_I32(3, 4, 12, 8);
    setColor(image, r, 100, 105, 12);
    alg.setImage(image);
    alg.createModel(r);
    assertEquals(1.0f, alg.compute(3, 4), 1e-4);
    assertEquals(1.0f, alg.compute(14, 11), 1e-4);
    assertEquals(0, alg.compute(10, 30), 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 29 with Planar

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

the class TestLikelihoodHueSatHistInd_PL_U8 method multipleColors.

@Test
public void multipleColors() {
    LikelihoodHueSatHistInd_PL_U8 alg = new LikelihoodHueSatHistInd_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);
    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 30 with Planar

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

the class TestTrackerMeanShiftComaniciu2003 method track.

@Test
public void track() {
    InterpolatePixelS interpSB = FactoryInterpolation.bilinearPixelS(GrayF32.class, BorderType.EXTENDED);
    InterpolatePixelMB interpolate = FactoryInterpolation.createPixelPL(interpSB);
    LocalWeightedHistogramRotRect calcHistogram = new LocalWeightedHistogramRotRect(30, 3, 10, 3, 255, interpolate);
    TrackerMeanShiftComaniciu2003 alg = new TrackerMeanShiftComaniciu2003(false, 100, 1e-8f, 0.0f, 0.0f, 0.1f, calcHistogram);
    Planar<GrayF32> image = new Planar<>(GrayF32.class, 100, 150, 3);
    // odd width and height so samples land on pixels
    render(image, 50, 40, 21, 31);
    RectangleRotate_F32 found = new RectangleRotate_F32(50, 40, 21, 31, 0);
    alg.initialize(image, found);
    // test no change
    alg.track(image);
    check(alg.getRegion(), 50, 40, 21, 31, 0);
    // test translation
    render(image, 55, 34, 21, 31);
    alg.track(image);
    check(alg.getRegion(), 55, 34, 21, 31, 0);
    // test scale
    render(image, 55, 34, 23, 34);
    alg.track(image);
    assertEquals(alg.getRegion().cx, 55, 1f);
    assertEquals(alg.getRegion().cy, 34, 1f);
    assertEquals(alg.getRegion().width, 23, 1);
    assertEquals(alg.getRegion().height, 34, 1);
}
Also used : InterpolatePixelS(boofcv.alg.interpolate.InterpolatePixelS) GrayF32(boofcv.struct.image.GrayF32) RectangleRotate_F32(boofcv.struct.RectangleRotate_F32) InterpolatePixelMB(boofcv.alg.interpolate.InterpolatePixelMB) Planar(boofcv.struct.image.Planar) 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