Program: 151032
Project: 151032
Buggy source:
/** 
 * <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 ImageSingleBand>StereoDisparity<T,ImageUInt8> 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;
  if (whichAlg == DisparityAlgorithms.RECT_FIVE)   maxError*=3;
  DisparitySelect select;
  if (imageType == ImageUInt8.class) {
    select=selectDisparity_S32((int)maxError,validateRtoL,texture);
  }
 else   if (imageType == ImageFloat32.class) {
    select=selectDisparity_F32((int)maxError,validateRtoL,texture);
  }
 else {
    throw new IllegalArgumentException("String_Node_Str");
  }
  DisparityScoreRowFormat<T,ImageUInt8> alg=null;
switch (whichAlg) {
case RECT:
    if (imageType == ImageUInt8.class) {
      alg=FactoryStereoDisparityAlgs.scoreDisparitySadRect_U8(minDisparity,maxDisparity,regionRadiusX,regionRadiusY,select);
    }
 else     if (imageType == ImageSInt16.class) {
      alg=FactoryStereoDisparityAlgs.scoreDisparitySadRect_S16(minDisparity,maxDisparity,regionRadiusX,regionRadiusY,select);
    }
 else     if (imageType == ImageFloat32.class) {
      alg=FactoryStereoDisparityAlgs.scoreDisparitySadRect_F32(minDisparity,maxDisparity,regionRadiusX,regionRadiusY,select);
    }
  break;
case RECT_FIVE:
if (imageType == ImageUInt8.class) {
  alg=FactoryStereoDisparityAlgs.scoreDisparitySadRectFive_U8(minDisparity,maxDisparity,regionRadiusX,regionRadiusY,select);
}
 else if (imageType == ImageSInt16.class) {
  alg=FactoryStereoDisparityAlgs.scoreDisparitySadRectFive_S16(minDisparity,maxDisparity,regionRadiusX,regionRadiusY,select);
}
 else if (imageType == ImageFloat32.class) {
  alg=FactoryStereoDisparityAlgs.scoreDisparitySadRectFive_F32(minDisparity,maxDisparity,regionRadiusX,regionRadiusY,select);
}
break;
default :
throw new IllegalArgumentException("String_Node_Str" + whichAlg);
}
if (alg == null) throw new RuntimeException("String_Node_Str" + imageType.getSimpleName());
return new WrapDisparitySadRect<T,ImageUInt8>(alg);
}

Fixed version (ground truth):
/** 
 * <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 ImageSingleBand>StereoDisparity<T,ImageUInt8> 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;
  if (whichAlg == DisparityAlgorithms.RECT_FIVE)   maxError*=3;
  DisparitySelect select;
  if (imageType == ImageUInt8.class || imageType == ImageSInt16.class) {
    select=selectDisparity_S32((int)maxError,validateRtoL,texture);
  }
 else   if (imageType == ImageFloat32.class) {
    select=selectDisparity_F32((int)maxError,validateRtoL,texture);
  }
 else {
    throw new IllegalArgumentException("String_Node_Str");
  }
  DisparityScoreRowFormat<T,ImageUInt8> alg=null;
switch (whichAlg) {
case RECT:
    if (imageType == ImageUInt8.class) {
      alg=FactoryStereoDisparityAlgs.scoreDisparitySadRect_U8(minDisparity,maxDisparity,regionRadiusX,regionRadiusY,select);
    }
 else     if (imageType == ImageSInt16.class) {
      alg=FactoryStereoDisparityAlgs.scoreDisparitySadRect_S16(minDisparity,maxDisparity,regionRadiusX,regionRadiusY,select);
    }
 else     if (imageType == ImageFloat32.class) {
      alg=FactoryStereoDisparityAlgs.scoreDisparitySadRect_F32(minDisparity,maxDisparity,regionRadiusX,regionRadiusY,select);
    }
  break;
case RECT_FIVE:
if (imageType == ImageUInt8.class) {
  alg=FactoryStereoDisparityAlgs.scoreDisparitySadRectFive_U8(minDisparity,maxDisparity,regionRadiusX,regionRadiusY,select);
}
 else if (imageType == ImageSInt16.class) {
  alg=FactoryStereoDisparityAlgs.scoreDisparitySadRectFive_S16(minDisparity,maxDisparity,regionRadiusX,regionRadiusY,select);
}
 else if (imageType == ImageFloat32.class) {
  alg=FactoryStereoDisparityAlgs.scoreDisparitySadRectFive_F32(minDisparity,maxDisparity,regionRadiusX,regionRadiusY,select);
}
break;
default :
throw new IllegalArgumentException("String_Node_Str" + whichAlg);
}
if (alg == null) throw new RuntimeException("String_Node_Str" + imageType.getSimpleName());
return new WrapDisparitySadRect<T,ImageUInt8>(alg);
}