Commit fdb5e16e authored by Edwin Carlinet's avatar Edwin Carlinet

Merge branch 'fix-sauvola-k-param-passing' into 'master'

sauvola-ms: fix passing k parameter(s)

See merge request olena/olena!4
parents d6e687f8 28495c94
......@@ -54,11 +54,6 @@ namespace scribo
namespace internal
{
extern double k2;
extern double k3;
extern double k4;
using namespace mln;
......@@ -91,7 +86,7 @@ namespace scribo
sauvola_formula formula_;
sauvola_ms_functor(const I& input, double R,
sauvola_ms_functor(const I& input, double K, double R,
const image2d<value::int_u8>&e_2,
unsigned i, unsigned q);
......@@ -106,15 +101,6 @@ namespace scribo
# ifndef MLN_INCLUDE_ONLY
# ifndef MLN_WO_GLOBAL_VARS
double k2 = SCRIBO_DEFAULT_SAUVOLA_K;
double k3 = SCRIBO_DEFAULT_SAUVOLA_K;
double k4 = SCRIBO_DEFAULT_SAUVOLA_K;
# endif // ! MLN_WO_GLOBAL_VARS
inline
unsigned my_find_root(image2d<unsigned>& parent, unsigned x)
{
......@@ -127,6 +113,7 @@ namespace scribo
template <typename I>
sauvola_ms_functor<I>::sauvola_ms_functor(const I& input,
double K,
double R,
const image2d<value::int_u8>&e_2,
unsigned i, unsigned q)
......@@ -135,6 +122,7 @@ namespace scribo
i(i),
q(q),
pxl(input),
K_(K),
R_(R),
i_(i)
{
......@@ -166,12 +154,6 @@ namespace scribo
dp = negative_offsets_wrt(input, c8());
n_nbhs = dp.nelements();
if (i == 2)
K_ = binarization::internal::k2;
else if (i == 3)
K_ = binarization::internal::k3;
else
K_ = binarization::internal::k4;
}
......
......@@ -28,6 +28,18 @@
#ifndef SCRIBO_BINARIZATION_SAUVOLA_MS_HH
# define SCRIBO_BINARIZATION_SAUVOLA_MS_HH
// Setup default Sauvola's formula parameters values at different scales.
//
// Values are set according to the following reference:
// Lazzara, G. and Géraud, T.: Efficient multiscale Sauvola’s binarization.
// IJDAR 2013, DOI 10.1007/s10032-013-0209-0
//
// "According to our experiment using k2 = 0.2, k3 = 0.3 and k4 = 0.5
// gives good results."
# define SCRIBO_DEFAULT_SAUVOLA_MS_K2 0.2
# define SCRIBO_DEFAULT_SAUVOLA_MS_K3 0.3
# define SCRIBO_DEFAULT_SAUVOLA_MS_K4 0.5
/// \file
///
/// \brief Binarize an image using a multi-scale implementation of
......@@ -97,12 +109,14 @@ namespace scribo
\param[in] w_1 The window size used to compute stats.
\param[in] s The scale factor used for the first subscaling
(usually 2 or 3 is enough).
\param[in] k2 Sauvola's K parameter for the lowest scale.
\param[in] k3 Sauvola's K parameter for the medium scales.
\param[in] k4 Sauvola's K parameter for the highest scale.
\param[out] integral_sum_sum_2 Integral image of sum and squared
sum.
Sauvola's formula parameter K is set to 0.34. \p w_1 and \p
lambda_min_1 are expressed according to the image at scale 0,
i.e. the original size.
\p w_1 and \p lambda_min_1 are expressed according to the image
at scale 0, i.e. the original size.
\return A Boolean image.
......@@ -127,12 +141,13 @@ namespace scribo
template <typename I>
mln_ch_value(I,bool)
sauvola_ms(const Image<I>& input_1, unsigned w_1,
unsigned s,
unsigned s, double k2, double k3, double k4,
image2d<mln::util::couple<double,double> >& integral_sum_sum_2);
/// \overload
/// The integral image is not returned.
/// K is set to 0.34.
/// Sauvola's K is set to the default on each scale, i.e.
/// 0.2 (lowest) / 0.3 (medium) / 0.5 (highest).
///
/// \ingroup grpalgobinsauvola
//
......@@ -142,7 +157,8 @@ namespace scribo
/// \overload
/// The integral image is not returned.
/// K is set to 0.34.
/// Sauvola's K parameter is set to the default on each scale,
/// i.e. 0.2 (lowest) / 0.3 (medium) / 0.5 (highest).
/// s is set to 3.
///
/// \ingroup grpalgobinsauvola
......@@ -152,15 +168,16 @@ namespace scribo
sauvola_ms(const Image<I>& input_1, unsigned w_1);
/// \overload
/// Allow to specify a different k parameter for each scale.
/// Sauvola's K parameter is set to the default on each scale,
/// i.e. 0.2 (lowest) / 0.3 (medium) / 0.5 (highest).
//
template <typename I>
mln_ch_value(I,bool)
sauvola_ms(const Image<I>& input_1, unsigned w_1, unsigned s,
double k2, double k3, double k4);
sauvola_ms(const Image<I>& input_1, unsigned w_1, unsigned s);
/// \overload
/// Allow to specify the same k parameter for all scales.
/// Allow to specify the same value for Sauvola's K parameter
/// on all scales.
//
template <typename I>
mln_ch_value(I,bool)
......@@ -193,7 +210,7 @@ namespace scribo
image2d<int_u8>
compute_t_n_and_e_2(const image2d<int_u8>& sub, image2d<int_u8>& e_2,
unsigned lambda_min, unsigned lambda_max,
unsigned s,
unsigned s, double k,
unsigned q, unsigned i, unsigned w,
const image2d<mln::util::couple<double,double> >& integral_sum_sum_2)
{
......@@ -210,7 +227,7 @@ namespace scribo
// 1st pass
scribo::binarization::internal::sauvola_ms_functor< image2d<int_u8> >
f(sub, SCRIBO_DEFAULT_SAUVOLA_R, e_2, i, q);
f(sub, k, SCRIBO_DEFAULT_SAUVOLA_R, e_2, i, q);
scribo::canvas::integral_browsing(integral_sum_sum_2,
ratio,
w_local_w, w_local_h,
......@@ -820,7 +837,7 @@ namespace scribo
template <typename I>
mln_ch_value(I,bool)
sauvola_ms(const Image<I>& input_1_, unsigned w_1,
unsigned s,
unsigned s, double k2, double k3, double k4,
image2d<mln::util::couple<double,double> >& integral_sum_sum_2)
{
mln_trace("scribo::binarization::sauvola_ms");
......@@ -935,7 +952,7 @@ namespace scribo
t_ima[i] = internal::compute_t_n_and_e_2(sub_ima[i], e_2,
(max_s2 * q_2) / (q_2) * min_coef,
mln_max(unsigned),
s,
s, k4,
q, i, w_work,
integral_sum_sum_2);
}
......@@ -947,7 +964,7 @@ namespace scribo
t_ima[i] = internal::compute_t_n_and_e_2(sub_ima[i], e_2,
max_s2 / (q_2) * min_coef,
max_s2 * q_2,
s,
s, k3,
q, i, w_work,
integral_sum_sum_2);
}
......@@ -959,7 +976,8 @@ namespace scribo
// FIXME: was '0'. '2' is to avoid too much noise with k=0.2.
2,
max_s2,
s, 1, 2, w_work,
s, k2,
1, 2, w_work,
integral_sum_sum_2);
}
......@@ -1031,6 +1049,7 @@ namespace scribo
template <typename I>
mln_ch_value(I,bool)
sauvola_ms(const Image<I>& input_1_, unsigned w_1, unsigned s,
double k2, double k3, double k4,
image2d<mln::util::couple<double,double> >& integral_sum_sum_2)
{
mln_trace("scribo::binarization::sauvola_ms");
......@@ -1044,6 +1063,7 @@ namespace scribo
mln_ch_value(I,bool)
output = impl::generic::sauvola_ms(exact(input_1_), w_1, s,
k2, k3, k4,
integral_sum_sum_2);
return output;
......@@ -1051,7 +1071,8 @@ namespace scribo
template <typename I>
mln_ch_value(I,bool)
sauvola_ms(const Image<I>& input_1_, unsigned w_1, unsigned s)
sauvola_ms(const Image<I>& input_1_, unsigned w_1, unsigned s,
double k2, double k3, double k4)
{
mln_trace("scribo::binarization::sauvola_ms");
......@@ -1066,7 +1087,7 @@ namespace scribo
integral_t integral_sum_sum_2;
mln_ch_value(I,bool)
output = sauvola_ms(input_1_, w_1, s, integral_sum_sum_2);
output = sauvola_ms(input_1_, w_1, s, k2, k3, k4, integral_sum_sum_2);
return output;
}
......@@ -1076,20 +1097,21 @@ namespace scribo
mln_ch_value(I,bool)
sauvola_ms(const Image<I>& input_1, unsigned w_1)
{
return sauvola_ms(input_1, w_1, 3);
return sauvola_ms(input_1, w_1, 3,
SCRIBO_DEFAULT_SAUVOLA_MS_K2,
SCRIBO_DEFAULT_SAUVOLA_MS_K3,
SCRIBO_DEFAULT_SAUVOLA_MS_K4);
}
template <typename I>
mln_ch_value(I,bool)
sauvola_ms(const Image<I>& input_1, unsigned w_1, unsigned s,
double k2, double k3, double k4)
sauvola_ms(const Image<I>& input_1, unsigned w_1, unsigned s)
{
binarization::internal::k2 = k2;
binarization::internal::k3 = k3;
binarization::internal::k4 = k4;
return sauvola_ms(input_1, w_1, s);
return sauvola_ms(input_1, w_1, s,
SCRIBO_DEFAULT_SAUVOLA_MS_K2,
SCRIBO_DEFAULT_SAUVOLA_MS_K3,
SCRIBO_DEFAULT_SAUVOLA_MS_K4);
}
......@@ -1098,11 +1120,7 @@ namespace scribo
sauvola_ms(const Image<I>& input_1, unsigned w_1, unsigned s,
double all_k)
{
binarization::internal::k2 = all_k;
binarization::internal::k3 = all_k;
binarization::internal::k4 = all_k;
return sauvola_ms(input_1, w_1, s);
return sauvola_ms(input_1, w_1, s, all_k, all_k, all_k);
}
......
......@@ -59,9 +59,9 @@ namespace scribo
\param[in] min_ntrue A site is set to 'True' in the output if it
is set to 'True' at least \p min_ntrue
components. Possible values: 1, 2, 3.
\param[in] k2 Sauvola's formula parameter.
\param[in] k3 Sauvola's formula parameter.
\param[in] k4 Sauvola's formula parameter.
\param[in] k2 Sauvola's K parameter for the lowest scale.
\param[in] k3 Sauvola's K parameter for the medium scales.
\param[in] k4 Sauvola's K parameter for the highest scale.
\p w_1 is expressed according to the image at scale 0, i.e. the
original size.
......@@ -77,7 +77,8 @@ namespace scribo
double k3, double k4);
/*! \overload
k2, k3 and k4 are set to \p K.
Allow to specify the same value for Sauvola's \p K parameter
on all scales.
\ingroup grpalgobinsauvola
*/
......@@ -88,7 +89,8 @@ namespace scribo
/*! \overload
k2, k3 and k4 are set to 0.34.
Sauvola's K parameter is set to the default on each scale,
i.e. 0.2 (lowest) / 0.3 (medium) / 0.5 (highest).
\ingroup grpalgobinsauvola
*/
......@@ -105,8 +107,8 @@ namespace scribo
template <typename I>
mln_ch_value(I, bool)
sauvola_ms_split(const Image<I>& input_1_, unsigned w_1,
unsigned s, unsigned min_ntrue, double k2,
double k3, double k4)
unsigned s, unsigned min_ntrue,
double k2, double k3, double k4)
{
mln_trace("scribo::binarization::sauvola_ms_split");
......@@ -119,18 +121,14 @@ namespace scribo
mln_ch_value(I, value::int_u8) r_i, g_i, b_i;
binarization::internal::k2 = k2;
binarization::internal::k3 = k3;
binarization::internal::k4 = k4;
// Split the rgb8 image into 3 intensity images.
mln::data::split(input_1, r_i, g_i, b_i);
bin_t r_b, g_b, b_b;
r_b = sauvola_ms(r_i, w_1, s);
g_b = sauvola_ms(g_i, w_1, s);
b_b = sauvola_ms(b_i, w_1, s);
r_b = sauvola_ms(r_i, w_1, s, k2, k3, k4);
g_b = sauvola_ms(g_i, w_1, s, k2, k3, k4);
b_b = sauvola_ms(b_i, w_1, s, k2, k3, k4);
border::resize(r_b, input_1.border());
border::resize(g_b, input_1.border());
......@@ -173,8 +171,7 @@ namespace scribo
sauvola_ms_split(const Image<I>& input_1, unsigned w_1,
unsigned s, unsigned min_ntrue, double K)
{
return sauvola_ms_split(input_1, w_1, s, min_ntrue,
K, K, K);
return sauvola_ms_split(input_1, w_1, s, min_ntrue, K, K, K);
}
......@@ -184,7 +181,9 @@ namespace scribo
unsigned s, unsigned min_ntrue)
{
return sauvola_ms_split(input_1, w_1, s, min_ntrue,
SCRIBO_DEFAULT_SAUVOLA_K);
SCRIBO_DEFAULT_SAUVOLA_MS_K2,
SCRIBO_DEFAULT_SAUVOLA_MS_K3,
SCRIBO_DEFAULT_SAUVOLA_MS_K4);
}
# endif // ! MLN_INCLUDE_ONLY
......
......@@ -64,13 +64,10 @@ static const scribo::debug::opt_data opt_desc[] =
// name, description, arguments, check args function, number of args, default arg
{ "debug-prefix", "Enable debug image outputs. Prefix image name with that "
"given prefix.", "<prefix>", 0, 1, 0 },
{ "all-k", "Sauvola's formulae parameter. Set it globally for all scales.",
"<value>", 0, 1, "0.34" },
{ "k2", "Force Sauvola's formulae parameter value for scale 2", "<value>", 0, 1, 0 },
{ "k3", "Force Sauvola's formulae parameter value for scale 3", "<value>", 0, 1, 0 },
{ "k4", "Force Sauvola's formulae parameter value for scale 4", "<value>", 0, 1, 0 },
{ "all-k", "Sauvola's formula parameter k on all scales (no default)", "<value>", 0, 1, NULL },
{ "k2", "Sauvola's formula parameter k for lowest scale (default 0.2)", "<value>", 0, 1, NULL },
{ "k3", "Sauvola's formula parameter k for medium scales (default 0.3)", "<value>", 0, 1, NULL },
{ "k4", "Sauvola's formula parameter k for highest scale (default 0.5)", "<value>", 0, 1, NULL },
{ "s", "First subsampling ratio. Possible values: 2 or 3.", "ratio",
scribo::debug::check_sauvola_first_subsampling, 1, "3" },
......@@ -110,24 +107,32 @@ int main(int argc, char *argv[])
// First subsampling scale.
unsigned s = atoi(options.opt_value("s").c_str());
// Setting k parameter.
double k = atof(options.opt_value("all-k").c_str());
binarization::internal::k2 = k;
binarization::internal::k3 = k;
binarization::internal::k4 = k;
// Set default k parameter.
double k2 = SCRIBO_DEFAULT_SAUVOLA_MS_K2;
double k3 = SCRIBO_DEFAULT_SAUVOLA_MS_K3;
double k4 = SCRIBO_DEFAULT_SAUVOLA_MS_K4;
// Override k parameter for all scales.
if (options.is_set("all-k"))
{
double k = atof(options.opt_value("all-k").c_str());
k2 = k;
k3 = k;
k4 = k;
}
// Override k parameter for specific scales.
if (options.is_set("k2"))
binarization::internal::k2 = atof(options.opt_value("k2").c_str());
k2 = atof(options.opt_value("k2").c_str());
if (options.is_set("k3"))
binarization::internal::k3 = atof(options.opt_value("k3").c_str());
k3 = atof(options.opt_value("k3").c_str());
if (options.is_set("k4"))
binarization::internal::k4 = atof(options.opt_value("k4").c_str());
k4 = atof(options.opt_value("k4").c_str());
scribo::debug::logger() << "Using w_1=" << w_1 << " - s=" << s
<< " - k2=" << binarization::internal::k2
<< " - k3=" << binarization::internal::k3
<< " - k4=" << binarization::internal::k4
<< " - k2=" << k2
<< " - k3=" << k3
<< " - k4=" << k4
<< std::endl;
......@@ -147,7 +152,7 @@ int main(int argc, char *argv[])
// Binarize
image2d<bool>
output = scribo::binarization::sauvola_ms(input_1_gl, w_1, s);
output = scribo::binarization::sauvola_ms(input_1_gl, w_1, s, k2, k3, k4);
scribo::debug::logger().stop_time_logging("Binarized in");
......
......@@ -64,11 +64,10 @@ static const scribo::debug::opt_data opt_desc[] =
// name, description, arguments, check args function, number of args, default arg
{ "debug-prefix", "Enable debug image outputs. Prefix image name with that "
"given prefix.", "<prefix>", 0, 1, 0 },
{ "all-k", "Sauvola's formulae parameter", "<value>", 0, 1, "0.34" },
{ "k2", "Sauvola's formulae parameter", "<value>", 0, 1, 0 },
{ "k3", "Sauvola's formulae parameter", "<value>", 0, 1, 0 },
{ "k4", "Sauvola's formulae parameter", "<value>", 0, 1, 0 },
{ "all-k", "Sauvola's formula parameter k on all scales (no default)", "<value>", 0, 1, NULL },
{ "k2", "Sauvola's formula parameter k for lowest scale (default 0.2)", "<value>", 0, 1, NULL },
{ "k3", "Sauvola's formula parameter k for medium scales (default 0.3)", "<value>", 0, 1, NULL },
{ "k4", "Sauvola's formula parameter k for highest scale (default 0.5)", "<value>", 0, 1, NULL },
{ "s", "First subsampling ratio. Possible values: 2 or 3.", "ratio",
scribo::debug::check_sauvola_first_subsampling, 1, "3" },
......@@ -135,25 +134,32 @@ int main(int argc, char *argv[])
// First subsampling scale.
unsigned s = atoi(options.opt_value("s").c_str());
// Set default k parameter.
double k2 = SCRIBO_DEFAULT_SAUVOLA_MS_K2;
double k3 = SCRIBO_DEFAULT_SAUVOLA_MS_K3;
double k4 = SCRIBO_DEFAULT_SAUVOLA_MS_K4;
// Setting k parameter.
double k = atof(options.opt_value("all-k").c_str());
binarization::internal::k2 = k;
binarization::internal::k3 = k;
binarization::internal::k4 = k;
// Override k parameter for all scales.
if (options.is_set("all-k"))
{
double k = atof(options.opt_value("all-k").c_str());
k2 = k;
k3 = k;
k4 = k;
}
// Override k parameter for specific scales.
if (options.is_set("k2"))
binarization::internal::k2 = atof(options.opt_value("k2").c_str());
k2 = atof(options.opt_value("k2").c_str());
if (options.is_set("k3"))
binarization::internal::k3 = atof(options.opt_value("k3").c_str());
k3 = atof(options.opt_value("k3").c_str());
if (options.is_set("k4"))
binarization::internal::k4 = atof(options.opt_value("k4").c_str());
k4 = atof(options.opt_value("k4").c_str());
scribo::debug::logger() << "Using w_1=" << w_1 << " - s=" << s
<< " - k2=" << binarization::internal::k2
<< " - k3=" << binarization::internal::k3
<< " - k4=" << binarization::internal::k4
<< " - k2=" << k2
<< " - k3=" << k3
<< " - k4=" << k4
<< std::endl;
scribo::binarization::internal::scale_image_output = "scale_image.pgm";
......@@ -176,7 +182,7 @@ int main(int argc, char *argv[])
// Binarize.
image2d<bool>
output = scribo::binarization::sauvola_ms(input_1_gl, w_1, s);
output = scribo::binarization::sauvola_ms(input_1_gl, w_1, s, k2, k3, k4);
scribo::debug::logger().stop_time_logging("Binarized in");
......
......@@ -63,11 +63,10 @@ static const scribo::debug::opt_data opt_desc[] =
// name, description, arguments, check args function, number of args, default arg
{ "debug-prefix", "Enable debug image outputs. Prefix image name with that "
"given prefix.", "<prefix>", 0, 1, 0 },
{ "all-k", "Sauvola's formulae parameter", "<value>", 0, 1, "0.34" },
{ "k2", "Sauvola's formulae parameter", "<value>", 0, 1, "0.20" },
{ "k3", "Sauvola's formulae parameter", "<value>", 0, 1, "0.30" },
{ "k4", "Sauvola's formulae parameter", "<value>", 0, 1, "0.50" },
{ "all-k", "Sauvola's formula parameter k on all scales (no default)", "<value>", 0, 1, NULL },
{ "k2", "Sauvola's formula parameter k for lowest scale (default 0.2)", "<value>", 0, 1, NULL },
{ "k3", "Sauvola's formula parameter k for medium scales (default 0.3)", "<value>", 0, 1, NULL },
{ "k4", "Sauvola's formula parameter k for highest scale (default 0.4)", "<value>", 0, 1, NULL },
{ "lambda", "Set the maximum area of the background objects. It is only "
"useful if fg-extraction is enabled.", "<size>", 0, 1, "1024" },
......@@ -109,24 +108,32 @@ int main(int argc, char *argv[])
// First subsampling scale.
unsigned s = atoi(options.opt_value("s").c_str());
// Setting k parameter.
double k = atof(options.opt_value("all-k").c_str());
binarization::internal::k2 = k;
binarization::internal::k3 = k;
binarization::internal::k4 = k;
// Set default k parameter.
double k2 = SCRIBO_DEFAULT_SAUVOLA_MS_K2;
double k3 = SCRIBO_DEFAULT_SAUVOLA_MS_K3;
double k4 = SCRIBO_DEFAULT_SAUVOLA_MS_K4;
// Override k parameter for all scales.
if (options.is_set("all-k"))
{
double k = atof(options.opt_value("all-k").c_str());
k2 = k;
k3 = k;
k4 = k;
}
// Override k parameter for specific scales.
if (options.is_set("k2"))
binarization::internal::k2 = atof(options.opt_value("k2").c_str());
k2 = atof(options.opt_value("k2").c_str());
if (options.is_set("k3"))
binarization::internal::k3 = atof(options.opt_value("k3").c_str());
k3 = atof(options.opt_value("k3").c_str());
if (options.is_set("k4"))
binarization::internal::k4 = atof(options.opt_value("k4").c_str());
k4 = atof(options.opt_value("k4").c_str());
scribo::debug::logger() << "Using w_1=" << w_1 << " - s=" << s
<< " - k2=" << binarization::internal::k2
<< " - k3=" << binarization::internal::k3
<< " - k4=" << binarization::internal::k4
<< " - k2=" << k2
<< " - k3=" << k3
<< " - k4=" << k4
<< std::endl;
// Load
......@@ -148,7 +155,7 @@ int main(int argc, char *argv[])
// Binarize
image2d<bool>
output = scribo::binarization::sauvola_ms(fg_gl, w_1, s);
output = scribo::binarization::sauvola_ms(fg_gl, w_1, s, k2, k3, k4);
if (options.is_enabled("negate-output"))
logical::not_inplace(output);
......
......@@ -59,12 +59,10 @@ static const scribo::debug::opt_data opt_desc[] =
// name, description, arguments, check args function, number of args, default arg
{ "debug-prefix", "Enable debug image outputs. Prefix image name with that "
"given prefix.", "<prefix>", 0, 1, 0 },
{ "all-k", "Sauvola's formulae parameter. Set it globally for all scales.",
"<value>", 0, 1, "0.34" },
{ "k2", "Sauvola's formulae parameter", "<value>", 0, 1, 0 },
{ "k3", "Sauvola's formulae parameter", "<value>", 0, 1, 0 },
{ "k4", "Sauvola's formulae parameter", "<value>", 0, 1, 0 },
{ "all-k", "Sauvola's formula parameter k on all scales (no default)", "<value>", 0, 1, NULL },
{ "k2", "Sauvola's formula parameter k for lowest scale (default 0.2)", "<value>", 0, 1, NULL },
{ "k3", "Sauvola's formula parameter k for medium scales (default 0.3)", "<value>", 0, 1, NULL },
{ "k4", "Sauvola's formula parameter k for highest scale (default 0.5)", "<value>", 0, 1, NULL },
{ "min-ntrue", "The number of components in which a site must be set to 'True' in"
" order to be set to 'True' in the output (Possible values: 1, 2, 3).",
......@@ -104,25 +102,32 @@ int main(int argc, char *argv[])
unsigned s = atoi(options.opt_value("s").c_str());
unsigned min_ntrue = atoi(options.opt_value("min-ntrue").c_str());
// Set default k parameter.
double k2 = SCRIBO_DEFAULT_SAUVOLA_MS_K2;
double k3 = SCRIBO_DEFAULT_SAUVOLA_MS_K3;
double k4 = SCRIBO_DEFAULT_SAUVOLA_MS_K4;
// Setting k parameter.
double k = atof(options.opt_value("all-k").c_str());
binarization::internal::k2 = k;
binarization::internal::k3 = k;
binarization::internal::k4 = k;
// Override k parameter for all scales.
if (options.is_set("all-k"))
{
double k = atof(options.opt_value("all-k").c_str());
k2 = k;
k3 = k;
k4 = k;
}
// Override k parameter for specific scales.
if (options.is_set("k2"))
binarization::internal::k2 = atof(options.opt_value("k2").c_str());
k2 = atof(options.opt_value("k2").c_str());
if (options.is_set("k3"))
binarization::internal::k3 = atof(options.opt_value("k3").c_str());
k3 = atof(options.opt_value("k3").c_str());
if (options.is_set("k4"))
binarization::internal::k4 = atof(options.opt_value("k4").c_str());
k4 = atof(options.opt_value("k4").c_str());
scribo::debug::logger() << "Using w_1=" << w_1 << " - s=" << s
<< " - k2=" << binarization::internal::k2
<< " - k3=" << binarization::internal::k3
<< " - k4=" << binarization::internal::k4
<< " - k2=" << k2