def threshold_sauvola(image, window_size=15, k=0.2, r=None):
 if (r is None):
  (imin, imax) = dtype_limits(image, clip_negative=False)
  r = (0.5 * (imax - imin))
 (m, s) = _mean_std(image, window_size)
 return (m * (1 + (k * ((s / r) - 1))))

def threshold_sauvola ( image , window_size = 15 , k = 0.2 , r = None ) : if ( r is None ) : ( imin , imax ) = dtype_limits ( image , clip_negative = False ) r = ( 0.5 * ( imax - imin ) ) ( m , s ) = _mean_std ( image , window_size ) return ( m * ( 1 + ( k * ( ( s / r ) - 1 ) ) ) )
applies sauvola local threshold to an array .