Search in sources :

Example 6 with GrayF32

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

the class FactoryStereoDisparity method regionWta.

/**
 * <p>
 * Crates algorithms for computing dense disparity images up to pixel level accuracy.
 * </p>
 *
 * <p>
 * NOTE: For RECT_FIVE the size of the sub-regions it uses is what is specified.
 * </p>
 *
 * @param minDisparity Minimum disparity that it will check. Must be &ge; 0 and &lt; maxDisparity
 * @param maxDisparity Maximum disparity that it will calculate. Must be &gt; 0
 * @param regionRadiusX Radius of the rectangular region along x-axis.
 * @param regionRadiusY Radius of the rectangular region along y-axis.
 * @param maxPerPixelError Maximum allowed error in a region per pixel.  Set to &lt; 0 to disable.
 * @param validateRtoL Tolerance for how difference the left to right associated values can be.  Try 6
 * @param texture Tolerance for how similar optimal region is to other region.  Closer to zero is more tolerant.
 *                Try 0.1
 * @param imageType Type of input image.
 * @return Rectangular region based WTA disparity.algorithm.
 */
public static <T extends ImageGray<T>> StereoDisparity<T, GrayU8> regionWta(DisparityAlgorithms whichAlg, int minDisparity, int maxDisparity, int regionRadiusX, int regionRadiusY, double maxPerPixelError, int validateRtoL, double texture, Class<T> imageType) {
    double maxError = (regionRadiusX * 2 + 1) * (regionRadiusY * 2 + 1) * maxPerPixelError;
    // 3 regions are used not just one in this case
    if (whichAlg == DisparityAlgorithms.RECT_FIVE)
        maxError *= 3;
    DisparitySelect select;
    if (imageType == GrayU8.class || imageType == GrayS16.class) {
        select = selectDisparity_S32((int) maxError, validateRtoL, texture);
    } else if (imageType == GrayF32.class) {
        select = selectDisparity_F32((int) maxError, validateRtoL, texture);
    } else {
        throw new IllegalArgumentException("Unknown image type");
    }
    DisparityScoreRowFormat<T, GrayU8> alg = null;
    switch(whichAlg) {
        case RECT:
            if (imageType == GrayU8.class) {
                alg = FactoryStereoDisparityAlgs.scoreDisparitySadRect_U8(minDisparity, maxDisparity, regionRadiusX, regionRadiusY, select);
            } else if (imageType == GrayS16.class) {
                alg = FactoryStereoDisparityAlgs.scoreDisparitySadRect_S16(minDisparity, maxDisparity, regionRadiusX, regionRadiusY, select);
            } else if (imageType == GrayF32.class) {
                alg = FactoryStereoDisparityAlgs.scoreDisparitySadRect_F32(minDisparity, maxDisparity, regionRadiusX, regionRadiusY, select);
            }
            break;
        case RECT_FIVE:
            if (imageType == GrayU8.class) {
                alg = FactoryStereoDisparityAlgs.scoreDisparitySadRectFive_U8(minDisparity, maxDisparity, regionRadiusX, regionRadiusY, select);
            } else if (imageType == GrayS16.class) {
                alg = FactoryStereoDisparityAlgs.scoreDisparitySadRectFive_S16(minDisparity, maxDisparity, regionRadiusX, regionRadiusY, select);
            } else if (imageType == GrayF32.class) {
                alg = FactoryStereoDisparityAlgs.scoreDisparitySadRectFive_F32(minDisparity, maxDisparity, regionRadiusX, regionRadiusY, select);
            }
            break;
        default:
            throw new IllegalArgumentException("Unknown algorithms " + whichAlg);
    }
    if (alg == null)
        throw new RuntimeException("Image type not supported: " + imageType.getSimpleName());
    return new WrapDisparitySadRect<>(alg);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) DisparitySelect(boofcv.alg.feature.disparity.DisparitySelect) GrayS16(boofcv.struct.image.GrayS16) GrayU8(boofcv.struct.image.GrayU8) WrapDisparitySadRect(boofcv.abst.feature.disparity.WrapDisparitySadRect)

Example 7 with GrayF32

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

the class FactoryOrientation method sift.

/**
 * Creates an implementation of the SIFT orientation estimation algorithm
 *
 * @param configSS Configuration of the scale-space.  null for default
 * @param configOri  Orientation configuration. null for default
 * @param imageType Type of input image
 * @return SIFT orientation image
 */
public static <T extends ImageGray<T>> OrientationImage<T> sift(ConfigSiftScaleSpace configSS, ConfigSiftOrientation configOri, Class<T> imageType) {
    if (configSS == null)
        configSS = new ConfigSiftScaleSpace();
    configSS.checkValidity();
    OrientationHistogramSift<GrayF32> ori = FactoryOrientationAlgs.sift(configOri, GrayF32.class);
    SiftScaleSpace ss = new SiftScaleSpace(configSS.firstOctave, configSS.lastOctave, configSS.numScales, configSS.sigma0);
    return new OrientationSiftToImage<>(ori, ss, imageType);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) SiftScaleSpace(boofcv.alg.feature.detect.interest.SiftScaleSpace) ConfigSiftScaleSpace(boofcv.abst.feature.describe.ConfigSiftScaleSpace) ConfigSiftScaleSpace(boofcv.abst.feature.describe.ConfigSiftScaleSpace)

Example 8 with GrayF32

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

the class TestWrapDisparitySparseSadRect method compareToDense.

/**
 * Compare to the equivalent dense algorithm
 */
@Test
public void compareToDense() {
    // more stressful if not 0
    int minDisparity = 3;
    int maxDisparity = 12;
    GrayF32 left = new GrayF32(w, h);
    GrayF32 right = new GrayF32(w, h);
    StereoDisparity<GrayF32, GrayU8> validator = FactoryStereoDisparity.regionWta(DisparityAlgorithms.RECT, minDisparity, maxDisparity, r, r, -1, -1, -1, GrayF32.class);
    StereoDisparitySparse<GrayF32> alg = new WrapDisparitySparseSadRect<>(new ImplDisparitySparseScoreSadRect_F32(minDisparity, maxDisparity, r, r), new ImplSelectSparseBasicWta_F32());
    validator.process(left, right);
    GrayU8 expected = validator.getDisparity();
    alg.setImages(left, right);
    for (int y = 0; y < h; y++) {
        for (int x = 0; x < w; x++) {
            if (alg.process(x, y)) {
                double found = alg.getDisparity();
                assertEquals(minDisparity + expected.get(x, y), (int) found);
            } else {
                assertTrue(expected.get(x, y) > (maxDisparity - minDisparity));
            }
        }
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32) ImplSelectSparseBasicWta_F32(boofcv.alg.feature.disparity.impl.ImplSelectSparseBasicWta_F32) GrayU8(boofcv.struct.image.GrayU8) ImplDisparitySparseScoreSadRect_F32(boofcv.alg.feature.disparity.impl.ImplDisparitySparseScoreSadRect_F32) Test(org.junit.Test)

Example 9 with GrayF32

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

the class GeneralNonMaxSuppressionChecks method checkSubImage.

/**
 * When processing a sub-image it should produce the same results as when processing a regular image
 */
@Test
public void checkSubImage() {
    init();
    ImageMiscOps.fillGaussian(image, rand, 0, 2, -100, 100);
    // make every pixel as a candidate since I'm not sure which ones are extremes.
    for (int i = 0; i < image.height; i++) for (int j = 0; j < image.width; j++) {
        if (candidatesMin != null)
            candidatesMin.add(j, i);
        if (candidatesMax != null)
            candidatesMax.add(j, i);
    }
    // the original input image
    foundMin.reset();
    foundMax.reset();
    alg.process(image, candidatesMin, candidatesMax, foundMin, foundMax);
    int origMin = foundMin.size;
    int origMax = foundMax.size;
    // if sub-images are correctly handled this should produce identical results
    GrayF32 sub = BoofTesting.createSubImageOf(image);
    foundMin.reset();
    foundMax.reset();
    alg.process(sub, candidatesMin, candidatesMax, foundMin, foundMax);
    int subMin = foundMin.size;
    int subMax = foundMax.size;
    assertEquals(origMin, subMin);
    assertEquals(origMax, subMax);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) Test(org.junit.Test)

Example 10 with GrayF32

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

the class TestNonMaxLimiter method checkLimit.

/**
 * 4 features, but a max of 2 is requested.
 */
@Test
public void checkLimit() {
    GrayF32 intensity = new GrayF32(30, 25);
    intensity.set(10, 15, 20);
    intensity.set(12, 20, 25);
    intensity.set(1, 15, -20);
    intensity.set(1, 20, -25);
    NonMaxSuppression extractor = FactoryFeatureExtractor.nonmax(new ConfigExtract(1, 0, 0, true, true, true));
    NonMaxLimiter limiter = new NonMaxLimiter(extractor, 2);
    limiter.process(intensity);
    FastQueue<NonMaxLimiter.LocalExtreme> found = limiter.getLocalExtreme();
    assertEquals(2, found.size());
    for (int i = 0; i < found.size(); i++) {
        NonMaxLimiter.LocalExtreme a = found.get(i);
        assertEquals(a.getValue(), intensity.get(a.location.x, a.location.y));
        assertEquals(a.getValue() > 0, a.max);
        assertEquals(25, a.intensity, 1e-8);
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32) Test(org.junit.Test)

Aggregations

GrayF32 (boofcv.struct.image.GrayF32)530 Test (org.junit.Test)291 BufferedImage (java.awt.image.BufferedImage)81 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)76 GrayU8 (boofcv.struct.image.GrayU8)49 Planar (boofcv.struct.image.Planar)34 ArrayList (java.util.ArrayList)28 ImageBorder_F32 (boofcv.core.image.border.ImageBorder_F32)20 ImageGray (boofcv.struct.image.ImageGray)20 File (java.io.File)20 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)19 Se3_F64 (georegression.struct.se.Se3_F64)18 TupleDesc_F64 (boofcv.struct.feature.TupleDesc_F64)17 GrayS8 (boofcv.struct.image.GrayS8)16 ListDisplayPanel (boofcv.gui.ListDisplayPanel)14 PathLabel (boofcv.io.PathLabel)14 Kernel2D_F32 (boofcv.struct.convolve.Kernel2D_F32)13 GrayS16 (boofcv.struct.image.GrayS16)13 GrayS32 (boofcv.struct.image.GrayS32)13 Point2D_F64 (georegression.struct.point.Point2D_F64)13