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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations