bundles / skimage 0.26.1rc0.dev0+git20260530.b607368ff / skimage / filters / thresholding / threshold_sauvola
function
skimage.filters.thresholding:threshold_sauvola
source: /dev/scikit-image/src/skimage/filters/thresholding.py :1123
Signature
def threshold_sauvola ( image , window_size = 15 , k = 0.2 , r = None ) Summary
Applies Sauvola local threshold to an array. Sauvola is a modification of Niblack technique.
Extended Summary
In the original method a threshold T is calculated for every pixel in the image using the following formula
T = m(x,y) * (1 + k * ((s(x,y) / R) - 1))where m(x,y) and s(x,y) are the mean and standard deviation of pixel (x,y) neighborhood defined by a rectangular window with size w times w centered around the pixel. k is a configurable parameter that weights the effect of standard deviation. R is the maximum standard deviation of a grayscale image.
Parameters
image: (M, N[, ...]) ndarrayGrayscale input image.
window_size: int, or iterable of int, optionalWindow size specified as a single odd integer (3, 5, 7, …), or an iterable of length
image.ndimcontaining only odd integers (e.g.(1, 5, 5)).k: float, optionalValue of the positive parameter k.
r: float, optionalValue of R, the dynamic range of standard deviation. If None, set to the half of the image dtype range.
Returns
threshold: (M, N[, ...]) ndarrayThreshold mask. All pixels with an intensity higher than this value are assumed to be foreground.
Notes
This algorithm is originally designed for text recognition.
Examples
from skimage import data image = data.page() t_sauvola = threshold_sauvola(image, window_size=15, k=0.2) binary_image = image > t_sauvola✓
Aliases
-
skimage.filters.threshold_sauvola