27 #include <mln/core/image/image2d.hh>
28 #include <mln/value/rgb8.hh>
29 #include <mln/io/magick/load.hh>
30 #include <mln/io/pbm/save.hh>
32 #include <scribo/binarization/sauvola_ms_split.hh>
33 #include <scribo/debug/option_parser.hh>
34 #include <scribo/debug/logger.hh>
38 {
"input.*",
"An image." },
39 {
"output.pbm",
"A binary image." },
56 {
"debug-prefix",
"Enable debug image outputs. Prefix image name with that "
57 "given prefix.",
"<prefix>", 0, 1, 0 },
58 {
"all-k",
"Sauvola's formulae parameter. Set it globally for all scales.",
59 "<value>", 0, 1,
"0.34" },
61 {
"k2",
"Sauvola's formulae parameter",
"<value>", 0, 1, 0 },
62 {
"k3",
"Sauvola's formulae parameter",
"<value>", 0, 1, 0 },
63 {
"k4",
"Sauvola's formulae parameter",
"<value>", 0, 1, 0 },
65 {
"min-ntrue",
"The number of components in which a site must be set to 'True' in"
66 " order to be set to 'True' in the output (Possible values: 1, 2, 3).",
67 "<num>", scribo::debug::check_sauvola_split_ntrue, 1,
"2" },
68 {
"s",
"First subsampling ratio. Possible values: 2 or 3.",
"ratio",
69 scribo::debug::check_sauvola_first_subsampling, 1,
"3" },
70 {
"verbose",
"Enable verbose mode (mute, time, low, medium, full)",
71 "<mode>", scribo::debug::check_verbose_mode, 1,
"mute" },
72 {
"win-size",
"Window size at scale 1",
"<size>", 0, 1,
"101" },
77 int main(
int argc,
char *argv[])
80 using namespace scribo;
84 if (!options.parse(argc, argv))
88 if (options.is_set(
"debug-prefix"))
97 unsigned w_1 = atoi(options.opt_value(
"win-size").c_str());
100 unsigned s = atoi(options.opt_value(
"s").c_str());
101 unsigned min_ntrue = atoi(options.opt_value(
"min-ntrue").c_str());
105 double k = atof(options.opt_value(
"all-k").c_str());
106 binarization::internal::k2 = k;
107 binarization::internal::k3 = k;
108 binarization::internal::k4 = k;
111 if (options.is_set(
"k2"))
112 binarization::internal::k2 = atof(options.opt_value(
"k2").c_str());
113 if (options.is_set(
"k3"))
114 binarization::internal::k3 = atof(options.opt_value(
"k3").c_str());
115 if (options.is_set(
"k4"))
116 binarization::internal::k4 = atof(options.opt_value(
"k4").c_str());
119 <<
" - k2=" << binarization::internal::k2
120 <<
" - k3=" << binarization::internal::k3
121 <<
" - k4=" << binarization::internal::k4