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>
36 #include <scribo/table/rebuild.hh>
37 #include <scribo/table/erase.hh>
38 #include <scribo/primitive/extract/lines_h_thick.hh>
39 #include <scribo/primitive/extract/lines_v_thick.hh>
40 #include <scribo/make/debug_filename.hh>
42 int usage(
const char *name)
44 std::cout <<
"Usage: " << name <<
" <input.pbm> " << std::endl;
49 int main(
int argc,
char* argv[])
51 using namespace scribo;
55 return usage(argv[0]);
57 scribo::make::internal::debug_filename_prefix = argv[0];
65 value::label_16 nbboxes;
67 = scribo::primitive::extract::lines_h_thick(input,
72 = scribo::primitive::extract::lines_v_thick(input,
77 value::label_8 ncells;
79 = scribo::table::rebuild(input,
80 mln::make::couple(vlines.bboxes(), hlines.bboxes()),
85 std::cout << "ncells (including
background) = " << ncells << std::endl;
87 scribo::make::debug_filename("table_cells.ppm"));
88 io::pgm::
save(tables, scribo::make::debug_filename("table_cells.pgm"));
91 data::
fill((input_rgb | (pw::
value(tables) == pw::cst(0u))).rw(), literal::red);
92 io::ppm::
save(input_rgb, scribo::make::debug_filename("table_superposed.ppm"));
94 image2d<
bool> in_wo_tables = table::erase(input, hlines, vlines);
95 io::pbm::
save(in_wo_tables,
96 scribo::make::debug_filename("input_wo_tables.pbm"));