private void binarizeEntireImage() throws NotFoundException {
if (matrix == null) {
LuminanceSource source = getLuminanceSource();
if (source.getWidth() >= MINIMUM_DIMENSION && source.getHeight() >= MINIMUM_DIMENSION) {
byte[] luminances = source.getMatrix();
int width = source.getWidth();
int height = source.getHeight();
int subWidth = width >> 3;
int subHeight = height >> 3;
int[][] blackPoints = calculateBlackPoints(luminances, subWidth, subHeight, width);
matrix = new BitMatrix(width, height);
calculateThresholdForBlock(luminances, subWidth, subHeight, width, blackPoints, matrix);
} else {
matrix = super.getBlackMatrix();
}
}
}