29 #include <mln/core/image/image2d.hh>
30 #include <mln/value/int_u8.hh>
31 #include <mln/io/magick/all.hh>
32 #include <mln/data/transform.hh>
33 #include <mln/fun/v2v/rgb_to_luma.hh>
34 #include <mln/util/timer.hh>
35 #include <mln/logical/not.hh>
37 #include <scribo/binarization/sauvola_ms.hh>
38 #include <scribo/debug/option_parser.hh>
39 #include <scribo/debug/logger.hh>
43 {
"input.*",
"An image." },
44 {
"output.*",
"A binary image." },
53 {
"negate",
"Negate output image.",
false},
62 {
"debug-prefix",
"Enable debug image outputs. Prefix image name with that "
63 "given prefix.",
"<prefix>", 0, 1, 0 },
64 {
"all-k",
"Sauvola's formulae parameter. Set it globally for all scales.",
65 "<value>", 0, 1,
"0.34" },
67 {
"k2",
"Force Sauvola's formulae parameter value for scale 2",
"<value>", 0, 1, 0 },
68 {
"k3",
"Force Sauvola's formulae parameter value for scale 3",
"<value>", 0, 1, 0 },
69 {
"k4",
"Force Sauvola's formulae parameter value for scale 4",
"<value>", 0, 1, 0 },
72 {
"s",
"First subsampling ratio. Possible values: 2 or 3.",
"ratio",
73 scribo::debug::check_sauvola_first_subsampling, 1,
"3" },
74 {
"verbose",
"Enable verbose mode (mute, time, low, medium, full)",
75 "<mode>", scribo::debug::check_verbose_mode, 1,
"mute" },
76 {
"win-size",
"Window size at scale 1",
"<size>", 0, 1,
"101" },
85 int main(
int argc,
char *argv[])
88 using namespace scribo;
92 if (!options.parse(argc, argv))
96 if (options.is_set(
"debug-prefix"))
106 unsigned w_1 = atoi(options.opt_value(
"win-size").c_str());
108 unsigned s = atoi(options.opt_value(
"s").c_str());
111 double k = atof(options.opt_value(
"all-k").c_str());
112 binarization::internal::k2 = k;
113 binarization::internal::k3 = k;
114 binarization::internal::k4 = k;
117 if (options.is_set(
"k2"))
118 binarization::internal::k2 = atof(options.opt_value(
"k2").c_str());
119 if (options.is_set(
"k3"))
120 binarization::internal::k3 = atof(options.opt_value(
"k3").c_str());
121 if (options.is_set(
"k4"))
122 binarization::internal::k4 = atof(options.opt_value(
"k4").c_str());
125 <<
" - k2=" << binarization::internal::k2
126 <<
" - k3=" << binarization::internal::k3
127 <<
" - k4=" << binarization::internal::k4
149 if (options.is_enabled(
"negate"))