public class ThresholdSauvola
extends java.lang.Object
Intended for use as a preprocessing step in OCR it computes a binary image from an input gray image. It's
an adaptive algorithm and uses the local mean and standard deviation, as is shown in the equation below:
T(x,y) = m(x,y) * [ 1 + k * (s(x,y)/R - 1)]
where T(x,y) is the pixel's threshold, m(x,y) is the local mean, s(x,y) is the local deviation,
R is dynamic range of standard deviation, and k is a user specified threshold.
There are two tuning parameters 'k' a positive number and the the 'radius' of the local region. Recommended values are k=0.3 and radius=15. These were found by tuning against a set of text.
| Constructor and Description |
|---|
ThresholdSauvola(int radius,
float k,
boolean down)
Configures the algorithm.
|
| Modifier and Type | Method and Description |
|---|---|
float |
getK() |
int |
getRadius() |
boolean |
isDown() |
void |
process(GrayF32 input,
GrayU8 output)
Converts the input image into a binary image.
|
void |
setDown(boolean down) |
void |
setK(float k) |
void |
setRadius(int radius) |
public ThresholdSauvola(int radius,
float k,
boolean down)
radius - size of local radius. Try 15k - User specified threshold adjustment factor. Must be positive. Try 0.3down - Threshold down or uppublic void process(GrayF32 input, GrayU8 output)
input - Input image. Not modified.output - Output binary image. Modified.public float getK()
public void setK(float k)
public int getRadius()
public void setRadius(int radius)
public boolean isDown()
public void setDown(boolean down)