28 #include <mln/core/image/image2d.hh>
29 #include <mln/core/image/dmorph/image_if.hh>
30 #include <mln/value/label_8.hh>
31 #include <mln/value/label_16.hh>
32 #include <mln/pw/all.hh>
33 #include <mln/io/pbm/all.hh>
34 #include <mln/util/couple.hh>
35 #include <mln/data/compute.hh>
36 #include <mln/accu/maj_h.hh>
38 #include <scribo/table/rebuild.hh>
39 #include <scribo/table/erase.hh>
40 #include <scribo/primitive/extract/lines_h_discontinued.hh>
41 #include <scribo/primitive/extract/lines_v_discontinued.hh>
42 #include <scribo/make/debug_filename.hh>
44 int usage(
const char *name)
46 std::cout <<
"Usage: " << name <<
" <input.pbm> " << std::endl;
51 int main(
int argc,
char* argv[])
53 using namespace scribo;
57 return usage(argv[0]);
59 scribo::make::internal::debug_filename_prefix = argv[0];
67 value::label_16 nbboxes;
81 value::label_8 ncells;
83 = scribo::table::rebuild(input,
84 mln::make::couple(vlines.bboxes(), hlines.bboxes()),
89 std::cout << "ncells (including
background) = " << ncells << std::endl;
96 | (pw::
value(sup) == pw::cst(literal::black)), sup);
97 io::ppm::
save(sup, scribo::make::debug_filename("table_color_sup.ppm"));
99 io::ppm::
save(table_color,
100 scribo::make::debug_filename("table_cells.ppm"));
101 io::pgm::
save(tables, scribo::make::debug_filename("table_cells.pgm"));
104 data::
fill((input_rgb | (pw::
value(tables) == pw::cst(0u))).rw(), literal::red);
105 io::ppm::
save(input_rgb, scribo::make::debug_filename("table_superposed.ppm"));
107 image2d<
bool> in_wo_tables = table::erase(input, hlines, vlines);
108 io::pbm::
save(in_wo_tables,
109 scribo::make::debug_filename("input_wo_tables.pbm"));