private static void thresholdBlock ( byte [ ] luminances , int xoffset , int yoffset , int threshold , int stride , BitMatrix matrix ) { for ( int y = 0 , offset = yoffset * stride + xoffset ; y < BLOCK_SIZE ; y ++ , offset += stride ) { for ( int x = 0 ; x < BLOCK_SIZE ; x ++ ) { // Comparison needs to be <= so that black == 0 pixels are black even if the threshold is 0. if ( ( luminances [ offset + x ] & 0xFF ) <= threshold ) { matrix . set ( xoffset + x , yoffset + y ) ; } } } }
Applies a single threshold to a block of pixels .