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