$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Sauvola

Functions

template<typename I >
mln::trait::ch_value< I, bool >
::ret 
scribo::binarization::sauvola (const Image< I > &input, unsigned window_size, double K)
template<typename I >
mln::trait::ch_value< I, bool >
::ret 
scribo::binarization::sauvola (const Image< I > &input, unsigned window_size)
template<typename I >
mln::trait::ch_value< I, bool >
::ret 
scribo::binarization::sauvola (const Image< I > &input)
template<typename I >
mln::trait::ch_value< I, bool >
::ret 
scribo::binarization::sauvola_ms (const Image< I > &input_1, unsigned w_1, unsigned s, image2d< mln::util::couple< double, double > > &integral_sum_sum_2)
template<typename I >
mln::trait::ch_value< I, bool >
::ret 
scribo::binarization::sauvola_ms (const Image< I > &input_1, unsigned w_1, unsigned s)
template<typename I >
mln::trait::ch_value< I, bool >
::ret 
scribo::binarization::sauvola_ms (const Image< I > &input_1, unsigned w_1)
template<typename I >
mln::trait::ch_value< I, bool >
::ret 
scribo::binarization::sauvola_ms_split (const Image< I > &input_1, unsigned w_1, unsigned s, unsigned min_ntrue, double k2, double k3, double k4)
template<typename I >
mln::trait::ch_value< I, bool >
::ret 
scribo::binarization::sauvola_ms_split (const Image< I > &input_1, unsigned w_1, unsigned s, unsigned min_ntrue, double K)
template<typename I >
mln::trait::ch_value< I, bool >
::ret 
scribo::binarization::sauvola_ms_split (const Image< I > &input_1, unsigned w_1, unsigned s, unsigned min_ntrue)
template<typename I , typename J >
mln::trait::ch_value< I,
value::int_u8 >::ret 
scribo::binarization::sauvola_threshold (const Image< I > &input, unsigned window_size, double K)
template<typename I >
mln::trait::ch_value< I,
value::int_u8 >::ret 
scribo::binarization::sauvola_threshold (const Image< I > &input, unsigned window_size)
template<typename I >
mln::trait::ch_value< I,
value::int_u8 >::ret 
scribo::binarization::sauvola_threshold (const Image< I > &input)

Detailed Description

Sauvola's Binarization implementations.

It is well suited for classical document image binarization.

Scribo provides three variants of Sauvola's binarization algorithm :

These algorithms are based on the following article: sauvola00pr . All of them are implemented using integral images for best performance shafait2008drr.

Sauvola's algorithm is a local thresholding method. Based on the mean and the standard deviation of a sliding centered window, it computes a local threshold for each pixel.

The following formula is used:

\[T(p) = m(p) + [1 + k * (\frac{s(p)}{R} - 1)]\]

Where p is the central window point, m(p) and s(p) are, respectively, the mean and the standard deviation of the window centered to point p.

k is user-defined parameter. According to badekas2005ppriaa, this parameter is set to 0.34. However, it is possible to pass a different value and change the object sharpness.

The window size is also a user-defined parameter. In scribo::binarization::sauvola, it has to be adapted to the size of the binarized objects. In case of a document image with mixed objects of various size, we advice you to use the multi-scale version scribo::binarization::sauvola_ms. In this version, the window size parameter is adapted at each scale and both large and small objects are correctly retrieved at the same time.

input_sauvola_sharpness.png
Input image.
output_k_0_03.png
sauvola_ms with k=0.03.
output_k_0_34.png
sauvola_ms with k=0.34.
output_k_0_60.png
sauvola_ms with k=0.60.

scribo::binarization::sauvola_threshold variants return an image of thresholds. The latter can be used afterwards to binarize the input image.


See Also
src/binarization/sauvola.cc src/binarization/sauvola_ms.cc sauvola_ms_split.cc


comparison

Compare results between all Sauvola's implementations. The window size is set to 51 and k is set to 0.34.

input_sauvola_bench.png
Input image.
output_sauvola.png
Binarization using scribo::binarization::sauvola
output_sauvola_ms.png
Binarization using scribo::binarization::sauvola_ms
output_sauvola_ms_split.png
Binarization using scribo::binarization::sauvola_split

Function Documentation

template<typename I >
mln::trait::ch_value< I , bool >::ret scribo::binarization::sauvola ( const Image< I > &  input,
unsigned  window_size,
double  K 
)

Convert an image into a binary image.

Parameters
[in]inputA greyscale image.
[in]window_sizeThe window size.
[in]KSauvola's formulae constant.
Returns
A binary image.
template<typename I >
mln::trait::ch_value< I , bool >::ret scribo::binarization::sauvola ( const Image< I > &  input,
unsigned  window_size 
)

Convert an image into a binary image.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Sauvola's formulae constant K is set to 0.34.

Parameters
[in]inputA grayscale image.
[in]window_sizeThe window size.
Returns
A binary image.
template<typename I >
mln::trait::ch_value< I , bool >::ret scribo::binarization::sauvola ( const Image< I > &  input)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. The window size is set to 11.

template<typename I >
mln::trait::ch_value< I , bool >::ret scribo::binarization::sauvola_ms ( const Image< I > &  input_1,
unsigned  w_1,
unsigned  s,
image2d< mln::util::couple< double, double > > &  integral_sum_sum_2 
)

Binarize an image using a multi-scale implementation of Sauvola's algoritm.

Parameters
[in]input_1A grayscale image.
[in]w_1The window size used to compute stats.
[in]sThe scale factor used for the first subscaling (usually 2 or 3 is enough).
[out]integral_sum_sum_2Integral image of sum and squared sum.

Sauvola's formula parameter K is set to 0.34. w_1 and lambda_min_1 are expressed according to the image at scale 0, i.e. the original size.

Returns
A Boolean image.

In this implementation, the input image is subscaled at three different scales. For each subscale image, Sauvola's is applied and relevant objects are preserved. The results of the three scales is merged and areas of the input image are marked with the appropriate scale to use for final binarization. Finally, the input image is binarized, using, for each pixel, the correct window size of the scale where it has been retrieved.

This implementation is very useful for document image with heterogeneous object sizes.

Its implementation is meant to be the fastest as possible. For instance, statistics computation is based on integral images shafait2008drr.

template<typename I >
mln::trait::ch_value< I , bool >::ret scribo::binarization::sauvola_ms ( const Image< I > &  input_1,
unsigned  w_1,
unsigned  s 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.The integral image is not returned.

K is set to 0.34.

template<typename I >
mln::trait::ch_value< I , bool >::ret scribo::binarization::sauvola_ms ( const Image< I > &  input_1,
unsigned  w_1 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.The integral image is not returned.

K is set to 0.34. s is set to 3.

template<typename I >
mln::trait::ch_value< I , bool >::ret scribo::binarization::sauvola_ms_split ( const Image< I > &  input_1,
unsigned  w_1,
unsigned  s,
unsigned  min_ntrue,
double  k2,
double  k3,
double  k4 
)

Binarize a color image merging the binarization of each component using Sauvola's algorithm.

Parameters
[in]input_1A color image.
[in]w_1The window size used to compute stats.
[in]sThe scale factor used for the first subscaling.
[in]min_ntrueA site is set to 'True' in the output if it is set to 'True' at least min_ntrue components. Possible values: 1, 2, 3.
[in]k2Sauvola's formula parameter.
[in]k3Sauvola's formula parameter.
[in]k4Sauvola's formula parameter.

w_1 is expressed according to the image at scale 0, i.e. the original size.

Returns
A Boolean image.
template<typename I >
mln::trait::ch_value< I , bool >::ret scribo::binarization::sauvola_ms_split ( const Image< I > &  input_1,
unsigned  w_1,
unsigned  s,
unsigned  min_ntrue,
double  K 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. k2, k3 and k4 are set to K.

template<typename I >
mln::trait::ch_value< I , bool >::ret scribo::binarization::sauvola_ms_split ( const Image< I > &  input_1,
unsigned  w_1,
unsigned  s,
unsigned  min_ntrue 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. k2, k3 and k4 are set to 0.34.

template<typename I , typename J >
mln::trait::ch_value< I , value::int_u8 >::ret scribo::binarization::sauvola_threshold ( const Image< I > &  input,
unsigned  window_size,
double  K 
)

Compute an image of local threshold using Sauvola algorithm.

Parameters
[in]inputA gray level image.
[in]window_sizeThe window size.
[in]KControls the threshold value in the local window.
Returns
An image of local thresholds.
template<typename I >
mln::trait::ch_value< I , value::int_u8 >::ret scribo::binarization::sauvola_threshold ( const Image< I > &  input,
unsigned  window_size 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.K is set to 0.34.

template<typename I >
mln::trait::ch_value< I , value::int_u8 >::ret scribo::binarization::sauvola_threshold ( const Image< I > &  input)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.The window size is set to 11.