use of georegression.struct.shapes.RectangleLength2D_I32 in project BoofCV by lessthanoptimal.
the class TestLikelihoodHueSatHistCoupled_PL_U8 method convertToHueSat.
@Test
public void convertToHueSat() {
LikelihoodHueSatHistCoupled_PL_U8 alg = new LikelihoodHueSatHistCoupled_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);
int index = indexH * 30 + indexS;
assertEquals(1.0, alg.bins[index], 1e-4);
}
use of georegression.struct.shapes.RectangleLength2D_I32 in project BoofCV by lessthanoptimal.
the class TestLikelihoodHueSatHistCoupled_PL_U8 method numBins.
@Test
public void numBins() {
LikelihoodHueSatHistCoupled_PL_U8 alg = new LikelihoodHueSatHistCoupled_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.numHistogramBins);
assertEquals(30 * 30, alg.bins.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);
}
use of georegression.struct.shapes.RectangleLength2D_I32 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 georegression.struct.shapes.RectangleLength2D_I32 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 georegression.struct.shapes.RectangleLength2D_I32 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);
}
Aggregations