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 ≥ 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 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);
}
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 ≥ 0 and < maxDisparity
* @param maxDisparity Maximum disparity that it will calculate. Must be > 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 < 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 ≤ 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);
}
Aggregations