30 #include <mln/io/magick/load.hh>
32 #include <scribo/toolchain/text_in_picture.hh>
33 #include <scribo/debug/option_parser.hh>
34 #include <scribo/debug/logger.hh>
36 #include <mln/world/rgb/invert.hh>
37 #include <scribo/primitive/merge/components.hh>
41 {
"input.*",
"An image." },
42 {
"output.ppm",
"A color image where the text is highlighted." },
50 {
"fg-extraction",
"Detect and slit foreground/background components. (default: disabled)",
false },
51 {
"ms-bin",
"Use a multi-scale binarization. (default: enabled)",
true },
60 {
"debug-prefix",
"Enable debug image outputs. Prefix image name with that "
61 "given prefix.",
"<prefix>", 0, 1, 0 },
62 {
"max-dim-size",
"Set the maximum size of the largest image dimension.",
"<size>", 0, 1,
"1024" },
63 {
"lambda",
"Set the maximum area of the background objects. It is only useful if fg-extraction is enabled.",
"<size>",
65 {
"verbose",
"Enable verbose mode", 0, 0, 0, 0 },
70 int main(
int argc,
char* argv[])
72 using namespace scribo;
73 using namespace scribo::primitive;
78 if (!options.parse(argc, argv))
81 if (options.is_set(
"debug-prefix"))
93 bool verbose = options.is_set(
"verbose");
94 unsigned max_dim_size = atoi(options.opt_value(
"max-dim-size").c_str());
95 bool fg_extraction = options.is_enabled(
"fg-extraction");
96 bool multi_scale_bin = options.is_enabled(
"ms-bin");
97 unsigned lambda = atoi(options.opt_value(
"lambda").c_str());
100 std::cout <<
"Using max_dim_size = " << max_dim_size
101 <<
" - fg_extraction = " << fg_extraction
102 <<
" - multi_scale_bin = " << multi_scale_bin
103 <<
" - lambda = " << lambda << std::endl;
109 max_dim_size, lambda, verbose);
115 fg_extraction, multi_scale_bin,
116 max_dim_size, lambda, verbose);
123 merged_comps.labeled_image(),
124 merged_comps.nelements()),
125 options.arg(
"output.ppm"));
127 # ifndef SCRIBO_NDEBUG
133 "input_with_bboxes.ppm");
139 # endif // ! SCRIBO_NDEBUG
141 std::cout <<
"# objects = " << merged_comps.nelements() << std::endl;
143 return merged_comps.nelements() != 0;