public static int Maximum ( ImageSource fastBitmap , int startX , int startY , int width , int height ) { int max = 0 ; if ( fastBitmap . isGrayscale ( ) ) { for ( int i = startX ; i < height ; i ++ ) { for ( int j = startY ; j < width ; j ++ ) { int gray = fastBitmap . getRGB ( j , i ) ; if ( gray > max ) { max = gray ; } } } } else { for ( int i = startX ; i < height ; i ++ ) { for ( int j = startY ; j < width ; j ++ ) { int gray = fastBitmap . getG ( j , i ) ; if ( gray > max ) { max = gray ; } } } } return max ; }
Get maximum gray value in the image .