Search in sources :

Example 51 with Planar

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

the class TestDescribePointSurfPlanar method failShape.

@Test(expected = IllegalArgumentException.class)
public void failShape() {
    Planar<GrayF32> input = new Planar<>(GrayF32.class, width, height, 3);
    GImageMiscOps.addUniform(input, rand, 0, 200);
    DescribePointSurf<GrayF32> desc = new DescribePointSurf<>(GrayF32.class);
    DescribePointSurfPlanar<GrayF32> alg = new DescribePointSurfPlanar<>(desc, 4);
    GrayF32 gray = ConvertImage.average(input, null);
    gray.reshape(width - 1, height);
    alg.setImage(gray, input);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) Planar(boofcv.struct.image.Planar) Test(org.junit.Test)

Example 52 with Planar

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

the class TestGHistogramFeatureOps method histogram_pl.

@Test
public void histogram_pl() {
    for (Class type : supported) {
        Planar image = new Planar(type, width, height, 2);
        GImageMiscOps.fillUniform(image, rand, 0, 200);
        Histogram_F64 found = new Histogram_F64(50, 40);
        found.setRange(0, 0, 200);
        found.setRange(1, 0, 200);
        Histogram_F64 expected = new Histogram_F64(50, 40);
        expected.setRange(0, 0, 200);
        expected.setRange(1, 0, 200);
        GHistogramFeatureOps.histogram(image, found);
        if (type == GrayF32.class) {
            HistogramFeatureOps.histogram_F32(image, expected);
        } else {
            HistogramFeatureOps.histogram_U8(image, expected);
        }
        assertEquals(0, DescriptorDistance.euclidean(expected, found), 1e-8);
    }
}
Also used : Planar(boofcv.struct.image.Planar) Test(org.junit.Test)

Example 53 with Planar

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

the class TestHistogramFeatureOps method histogram_PL_U8_compareToSingle.

/**
 * Compare to single band image.  Results should be identical
 */
@Test
public void histogram_PL_U8_compareToSingle() {
    GrayU8 image = new GrayU8(width, height);
    ImageMiscOps.fillUniform(image, rand, 0, 255);
    Planar<GrayU8> ms = new Planar<>(GrayU8.class, width, height, 1);
    ms.setBand(0, image);
    TupleDesc_F64 expected = new TupleDesc_F64(256);
    Histogram_F64 found = new Histogram_F64(256);
    found.setRange(0, 0, 255);
    HistogramFeatureOps.histogram(image, 255, expected);
    HistogramFeatureOps.histogram_U8(ms, found);
    for (int i = 0; i < found.size(); i++) {
        assertEquals(expected.getDouble(i), found.getDouble(i), 1e-8);
    }
}
Also used : TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) Planar(boofcv.struct.image.Planar) GrayU8(boofcv.struct.image.GrayU8) Test(org.junit.Test)

Example 54 with Planar

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

the class TestPlanarConvolveDown method compareToSingleBand.

@Test
public void compareToSingleBand() {
    Kernel1D_S32 kernel = FactoryKernelGaussian.gaussian1D(GrayU8.class, -1, 3);
    ConvolveDown<GrayU8, GrayU8> downU8 = FactoryConvolveDown.convolveSB(kernel, BorderType.NORMALIZED, true, 2, GrayU8.class, GrayU8.class);
    Planar<GrayU8> original = new Planar<>(GrayU8.class, 20, 30, 3);
    Planar<GrayU8> found = new Planar<>(GrayU8.class, 10, 30, 3);
    GImageMiscOps.fillUniform(original, rand, 0, 100);
    GrayU8[] expected = new GrayU8[original.getNumBands()];
    for (int i = 0; i < expected.length; i++) {
        expected[i] = new GrayU8(found.width, found.height);
        downU8.process(original.getBand(i), expected[i]);
    }
    PlanarConvolveDown<GrayU8, GrayU8> alg = new PlanarConvolveDown<>(downU8, original.getNumBands());
    alg.process(original, found);
    for (int i = 0; i < expected.length; i++) {
        BoofTesting.assertEquals(expected[i], found.getBand(i), 1e-4);
    }
}
Also used : Kernel1D_S32(boofcv.struct.convolve.Kernel1D_S32) Planar(boofcv.struct.image.Planar) GrayU8(boofcv.struct.image.GrayU8) Test(org.junit.Test)

Example 55 with Planar

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

the class TestImageGradientThenReduce method stuff.

@Test
public void stuff() {
    HelperGradient gradient = new HelperGradient();
    HelperReduce reduce = new HelperReduce();
    Planar<GrayF32> input = new Planar<>(GrayF32.class, 10, 12, 3);
    GrayF32 outDerivX = new GrayF32(10, 12);
    GrayF32 outDerivY = new GrayF32(10, 12);
    ImageGradientThenReduce<Planar<GrayF32>, Planar<GrayF32>, GrayF32> alg = new ImageGradientThenReduce<>(gradient, reduce);
    alg.process(input, outDerivX, outDerivY);
    assertEquals(1, outDerivX.get(2, 3), 1e-4f);
    assertEquals(2, outDerivY.get(2, 3), 1e-4f);
    alg.setBorderType(BorderType.EXTENDED);
    assertTrue(gradient.setBorderCalled);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) 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