Search in sources :

Example 1 with DisparitySparseSelect

use of boofcv.alg.feature.disparity.DisparitySparseSelect in project BoofCV by lessthanoptimal.

the class FactoryStereoDisparity method regionSparseWta.

/**
 * WTA algorithms that computes disparity on a sparse per-pixel basis as requested..
 *
 * @param minDisparity Minimum disparity that it will check. Must be ≥ 0 and < maxDisparity
 * @param maxDisparity Maximum disparity that it will calculate. Must be > 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 < 0 to disable.
 * @param texture Tolerance for how similar optimal region is to other region.  Closer to zero is more tolerant.
 *                Try 0.1
 * @param subpixelInterpolation true to turn on sub-pixel interpolation
 * @param imageType Type of input image.
 * @param <T> Image type
 * @return Sparse disparity algorithm
 */
public static <T extends ImageGray<T>> StereoDisparitySparse<T> regionSparseWta(int minDisparity, int maxDisparity, int regionRadiusX, int regionRadiusY, double maxPerPixelError, double texture, boolean subpixelInterpolation, Class<T> imageType) {
    double maxError = (regionRadiusX * 2 + 1) * (regionRadiusY * 2 + 1) * maxPerPixelError;
    if (imageType == GrayU8.class) {
        DisparitySparseSelect<int[]> select;
        if (subpixelInterpolation)
            select = selectDisparitySparseSubpixel_S32((int) maxError, texture);
        else
            select = selectDisparitySparse_S32((int) maxError, texture);
        DisparitySparseScoreSadRect<int[], GrayU8> score = scoreDisparitySparseSadRect_U8(minDisparity, maxDisparity, regionRadiusX, regionRadiusY);
        return new WrapDisparitySparseSadRect(score, select);
    } else if (imageType == GrayF32.class) {
        DisparitySparseSelect<float[]> select;
        if (subpixelInterpolation)
            select = selectDisparitySparseSubpixel_F32((int) maxError, texture);
        else
            select = selectDisparitySparse_F32((int) maxError, texture);
        DisparitySparseScoreSadRect<float[], GrayF32> score = scoreDisparitySparseSadRect_F32(minDisparity, maxDisparity, regionRadiusX, regionRadiusY);
        return new WrapDisparitySparseSadRect(score, select);
    } else
        throw new RuntimeException("Image type not supported: " + imageType.getSimpleName());
}
Also used : GrayF32(boofcv.struct.image.GrayF32) WrapDisparitySparseSadRect(boofcv.abst.feature.disparity.WrapDisparitySparseSadRect) DisparitySparseSelect(boofcv.alg.feature.disparity.DisparitySparseSelect) GrayU8(boofcv.struct.image.GrayU8) DisparitySparseScoreSadRect(boofcv.alg.feature.disparity.DisparitySparseScoreSadRect)

Aggregations

WrapDisparitySparseSadRect (boofcv.abst.feature.disparity.WrapDisparitySparseSadRect)1 DisparitySparseScoreSadRect (boofcv.alg.feature.disparity.DisparitySparseScoreSadRect)1 DisparitySparseSelect (boofcv.alg.feature.disparity.DisparitySparseSelect)1 GrayF32 (boofcv.struct.image.GrayF32)1 GrayU8 (boofcv.struct.image.GrayU8)1