Search in sources :

Example 1 with DisparitySelect

use of boofcv.alg.feature.disparity.DisparitySelect 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 2 with DisparitySelect

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

the class FactoryStereoDisparity method regionSubpixelWta.

/**
 * <p>
 * Returns an algorithm for computing a dense disparity images with sub-pixel disparity 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. Try 3.
 * @param regionRadiusY Radius of the rectangular region along y-axis. Try 3.
 * @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.  Disable with a value &le; 0.
 *                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, GrayF32> regionSubpixelWta(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 = selectDisparitySubpixel_S32((int) maxError, validateRtoL, texture);
    } else if (imageType == GrayF32.class) {
        select = selectDisparitySubpixel_F32((int) maxError, validateRtoL, texture);
    } else {
        throw new IllegalArgumentException("Unknown image type");
    }
    DisparityScoreRowFormat<T, GrayF32> 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)

Aggregations

WrapDisparitySadRect (boofcv.abst.feature.disparity.WrapDisparitySadRect)2 DisparitySelect (boofcv.alg.feature.disparity.DisparitySelect)2 GrayF32 (boofcv.struct.image.GrayF32)2 GrayS16 (boofcv.struct.image.GrayS16)2 GrayU8 (boofcv.struct.image.GrayU8)2