public final class HybridBinarizer extends GlobalHistogramBinarizer
Modifier and Type | Field and Description |
---|---|
private static int |
BLOCK_SIZE |
private static int |
BLOCK_SIZE_MASK |
private static int |
BLOCK_SIZE_POWER |
private BitMatrix |
matrix |
private static int |
MIN_DYNAMIC_RANGE |
private static int |
MINIMUM_DIMENSION |
Constructor and Description |
---|
HybridBinarizer(LuminanceSource source) |
Modifier and Type | Method and Description |
---|---|
private static int[][] |
calculateBlackPoints(byte[] luminances,
int subWidth,
int subHeight,
int width,
int height)
Calculates a single black point for each block of pixels and saves it away.
|
private static void |
calculateThresholdForBlock(byte[] luminances,
int subWidth,
int subHeight,
int width,
int height,
int[][] blackPoints,
BitMatrix matrix)
For each block in the image, calculate the average black point using a 5x5 grid
of the blocks around it.
|
private static int |
cap(int value,
int max) |
Binarizer |
createBinarizer(LuminanceSource source)
Creates a new object with the same type as this Binarizer implementation, but with pristine
state.
|
BitMatrix |
getBlackMatrix()
Calculates the final BitMatrix once for all requests.
|
private static void |
thresholdBlock(byte[] luminances,
int xoffset,
int yoffset,
int threshold,
int stride,
BitMatrix matrix)
Applies a single threshold to a block of pixels.
|
getBlackRow
getHeight, getLuminanceSource, getWidth
private static final int BLOCK_SIZE_POWER
private static final int BLOCK_SIZE
private static final int BLOCK_SIZE_MASK
private static final int MINIMUM_DIMENSION
private static final int MIN_DYNAMIC_RANGE
private BitMatrix matrix
public HybridBinarizer(LuminanceSource source)
public BitMatrix getBlackMatrix() throws NotFoundException
getBlackMatrix
in class GlobalHistogramBinarizer
NotFoundException
- if image can't be binarized to make a matrixpublic Binarizer createBinarizer(LuminanceSource source)
Binarizer
createBinarizer
in class GlobalHistogramBinarizer
source
- The LuminanceSource this Binarizer will operate on.private static void calculateThresholdForBlock(byte[] luminances, int subWidth, int subHeight, int width, int height, int[][] blackPoints, BitMatrix matrix)
private static int cap(int value, int max)
private static void thresholdBlock(byte[] luminances, int xoffset, int yoffset, int threshold, int stride, BitMatrix matrix)
private static int[][] calculateBlackPoints(byte[] luminances, int subWidth, int subHeight, int width, int height)