Program: 11536
Project: 11536
Buggy source:
/** 
 * Compute the mean value of pixels of the source image in the sliding window.
 * @param tx       The x coordinate of a pixel in the current target tile.
 * @param ty       The y coordinate of a pixel in the current target tile.
 * @param srcData1 The product data for i band in case of complex product.
 * @param srcData2 The product data for q band in case of complex product.
 * @param nRgLooks number of range looks
 * @param nAzLooks number of azimuth looks
 * @return The mean value.
 */
private static double getMeanValue(final int tx,final int ty,final ProductData srcData1,final ProductData srcData2,final TileIndex srcIndex,final int nRgLooks,final int nAzLooks,final boolean isdB,final boolean isComplex){
  final int xStart=tx * nRgLooks;
  final int yStart=ty * nAzLooks;
  final int xEnd=xStart + nRgLooks;
  final int yEnd=yStart + nAzLooks;
  double meanValue=0.0;
  int offset;
  if (isdB) {
    for (int y=yStart; y < yEnd; y++) {
      offset=srcIndex.calculateStride(y);
      for (int x=xStart; x < xEnd; x++) {
        meanValue+=Math.pow(10,srcData1.getElemDoubleAt(x - offset) / 10.0);
      }
    }
    meanValue/=(nRgLooks * nAzLooks);
    return 10.0 * Math.log10(meanValue);
  }
 else   if (isComplex) {
    double i, q;
    int index;
    for (int y=yStart; y < yEnd; y++) {
      offset=srcIndex.calculateStride(y);
      for (int x=xStart; x < xEnd; x++) {
        index=x - offset;
        i=srcData1.getElemDoubleAt(index);
        q=srcData2.getElemDoubleAt(index);
        meanValue+=i * i + q * q;
      }
    }
  }
 else {
    for (int y=yStart; y < yEnd; y++) {
      offset=srcIndex.calculateStride(y);
      for (int x=xStart; x < xEnd; x++) {
        meanValue+=srcData1.getElemDoubleAt(x - offset);
      }
    }
  }
  return meanValue / (nRgLooks * nAzLooks);
}

Fixed version (ground truth):
/** 
 * Compute the mean value of pixels of the source image in the sliding window.
 * @param tx       The x coordinate of a pixel in the current target tile.
 * @param ty       The y coordinate of a pixel in the current target tile.
 * @param srcData1 The product data for i band in case of complex product.
 * @param srcData2 The product data for q band in case of complex product.
 * @param nRgLooks number of range looks
 * @param nAzLooks number of azimuth looks
 * @return The mean value.
 */
private static double getMeanValue(final int tx,final int ty,final ProductData srcData1,final ProductData srcData2,final TileIndex srcIndex,final int nRgLooks,final int nAzLooks,final boolean isdB,final boolean isComplex,final boolean isPolsar){
  final int xStart=tx * nRgLooks;
  final int yStart=ty * nAzLooks;
  final int xEnd=xStart + nRgLooks;
  final int yEnd=yStart + nAzLooks;
  double meanValue=0.0;
  int offset;
  if (isdB) {
    for (int y=yStart; y < yEnd; y++) {
      offset=srcIndex.calculateStride(y);
      for (int x=xStart; x < xEnd; x++) {
        meanValue+=Math.pow(10,srcData1.getElemDoubleAt(x - offset) / 10.0);
      }
    }
    meanValue/=(nRgLooks * nAzLooks);
    return 10.0 * Math.log10(meanValue);
  }
 else   if (isComplex && !isPolsar) {
    double i, q;
    int index;
    for (int y=yStart; y < yEnd; y++) {
      offset=srcIndex.calculateStride(y);
      for (int x=xStart; x < xEnd; x++) {
        index=x - offset;
        i=srcData1.getElemDoubleAt(index);
        q=srcData2.getElemDoubleAt(index);
        meanValue+=i * i + q * q;
      }
    }
  }
 else {
    for (int y=yStart; y < yEnd; y++) {
      offset=srcIndex.calculateStride(y);
      for (int x=xStart; x < xEnd; x++) {
        meanValue+=srcData1.getElemDoubleAt(x - offset);
      }
    }
  }
  return meanValue / (nRgLooks * nAzLooks);
}