29 #include <mln/core/image/image2d.hh>
30 #include <mln/value/rgb8.hh>
31 #include <mln/io/magick/load.hh>
32 #include <mln/io/pbm/save.hh>
33 #include <mln/data/transform.hh>
34 #include <mln/fun/v2v/rgb_to_luma.hh>
36 #include <scribo/binarization/sauvola_ms.hh>
37 #include <scribo/preprocessing/split_bg_fg.hh>
38 #include <scribo/debug/option_parser.hh>
39 #include <scribo/debug/logger.hh>
43 {
"input.*",
"An image." },
44 {
"output.pbm",
"A binary image." },
61 {
"debug-prefix",
"Enable debug image outputs. Prefix image name with that "
62 "given prefix.",
"<prefix>", 0, 1, 0 },
63 {
"all-k",
"Sauvola's formulae parameter",
"<value>", 0, 1,
"0.34" },
65 {
"k2",
"Sauvola's formulae parameter",
"<value>", 0, 1,
"0.20" },
66 {
"k3",
"Sauvola's formulae parameter",
"<value>", 0, 1,
"0.30" },
67 {
"k4",
"Sauvola's formulae parameter",
"<value>", 0, 1,
"0.50" },
69 {
"lambda",
"Set the maximum area of the background objects. It is only "
70 "useful if fg-extraction is enabled.",
"<size>", 0, 1,
"1024" },
71 {
"s",
"First subsampling ratio. Possible values: 2 or 3.",
"ratio",
72 scribo::debug::check_sauvola_first_subsampling, 1,
"3" },
73 {
"verbose",
"Enable verbose mode (mute, time, low, medium, full)",
74 "<mode>", scribo::debug::check_verbose_mode, 1,
"mute" },
75 {
"win-size",
"Window size at scale 1",
"<size>", 0, 1,
"101" },
82 int main(
int argc,
char *argv[])
85 using namespace scribo;
89 if (!options.parse(argc, argv))
93 if (options.is_set(
"debug-prefix"))
101 unsigned lambda = atoi(options.opt_value(
"lambda").c_str());
104 unsigned w_1 = atoi(options.opt_value(
"win-size").c_str());
107 unsigned s = atoi(options.opt_value(
"s").c_str());
110 double k = atof(options.opt_value(
"all-k").c_str());
111 binarization::internal::k2 = k;
112 binarization::internal::k3 = k;
113 binarization::internal::k4 = k;
116 if (options.is_set(
"k2"))
117 binarization::internal::k2 = atof(options.opt_value(
"k2").c_str());
118 if (options.is_set(
"k3"))
119 binarization::internal::k3 = atof(options.opt_value(
"k3").c_str());
120 if (options.is_set(
"k4"))
121 binarization::internal::k4 = atof(options.opt_value(
"k4").c_str());
124 <<
" - k2=" << binarization::internal::k2
125 <<
" - k3=" << binarization::internal::k3
126 <<
" - k4=" << binarization::internal::k4