sauvola_threshold
result = sauvola_threshold(image, window_size=, [k=0.5], [r=128])
Input: image, window_size, k, r · Output: result
What it is
image is an Image; window_size is a required odd positive integer. Sauvola's local threshold, T = mean * (1 + k * (stddev/r - 1)) computed per pixel over window_size, purpose-built for document/text images whose illumination drifts across the frame — a case a single global otsu cut cannot separate cleanly. k (typically 0.2–0.5) controls how strongly local contrast shifts the threshold; r is the expected dynamic range of the local stddev (128 for 8-bit images). Binarized with the same >= convention as threshold.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = sauvola_threshold(image, window_size=, [k=0.5], [r=128]) | image Imageimage is an Image.window_size —window_size is a required odd positive integer.k optional (default 0.5)k (typically 0.2–0.5) controls how strongly local contrast shifts the threshold.r optional (default 128)r is the expected dynamic range of the local stddev (128 for 8-bit images). | result Image | Returns a binary Image of the same dimensions. |
Examples
No documentation example calls this form yet. The Images chapter is where one belongs.
How it works
sauvola_threshold(image, window_size=, [k=0.5], [r=128]) — Sauvola's local threshold (T = mean*(1 + k*(stddev/r - 1)) over window_size), the standard choice for document/text images with uneven illumination that defeat a global otsu. window_size is a required keyword, same reasoning as adaptive_threshold's block_size above.
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.