/** * Computes the min-max value for each block in the image */ protected void computeStatistics(T input, int innerWidth, int innerHeight) { int statPixelStride = stats.getImageType().getNumBands(); int indexStats = 0; for (int y = 0; y < innerHeight; y += blockHeight) { for (int x = 0; x < innerWidth; x += blockWidth, indexStats += statPixelStride) { computeBlockStatistics(x,y,blockWidth,blockHeight,indexStats,input); } // handle the case where the image's width isn't evenly divisible by the block's width if( innerWidth != input.width ) { computeBlockStatistics(innerWidth,y,input.width-innerWidth,blockHeight,indexStats,input); indexStats += statPixelStride; } } // handle the case where the image's height isn't evenly divisible by the block's height if( innerHeight != input.height ) { int y = innerHeight; int blockHeight = input.height-innerHeight; for (int x = 0; x < innerWidth; x += blockWidth, indexStats += statPixelStride) { computeBlockStatistics(x,y,blockWidth,blockHeight,indexStats,input); } if( innerWidth != input.width ) { computeBlockStatistics(innerWidth,y,input.width-innerWidth,blockHeight,indexStats,input); } } }