33 #include <mln/core/image/image2d.hh>
35 #include <mln/io/magick/load.hh>
37 #include <scribo/toolchain/content_in_hdoc.hh>
38 #include <scribo/toolchain/text_in_doc_preprocess.hh>
40 #include <scribo/core/document.hh>
42 #include <scribo/debug/usage.hh>
43 #include <scribo/debug/logger.hh>
45 #include <scribo/preprocessing/crop_without_localization.hh>
46 #include <scribo/preprocessing/crop.hh>
48 #include <scribo/io/xml/save.hh>
49 #include <scribo/io/img/save.hh>
52 #include <mln/core/alias/neighb2d.hh>
53 #include <mln/labeling/compute.hh>
54 #include <mln/labeling/foreground.hh>
55 #include <mln/util/timer.hh>
59 const char *args_desc[][2] =
61 {
"input.tif",
"An image." },
62 {
"out.xml",
"Result of the document analysis." },
68 int main(
int argc,
char* argv[])
70 using namespace scribo;
75 "Document Image Analysis in Historical Documents",
104 const box2d& b = input.domain();
105 for_all_ncomponents(e, nlabels)
106 if (bbox(e).pmin().row() == b.pmin().row()
107 || bbox(e).pmax().row() == b.pmax().row()
108 || bbox(e).pmin().col() == b.pmin().col()
109 || bbox(e).pmax().col() == b.pmax().col())
110 data::
fill(((input_preproc | bbox(e)).rw()
111 | (pw::
value(lbl) == pw::cst(e))).rw(), false);
116 std::
string language = "";
117 bool find_line_seps = true;
118 bool find_whitespace_seps = true;
123 std::cout << "Analysing
document..." << std::endl;
125 doc = scribo::toolchain::
content_in_hdoc(input, input_preproc, denoise,
126 find_line_seps, find_whitespace_seps,
127 !language.empty(), language);
129 doc.set_filename(basename(argv[1]));
132 std::cout << "Saving results..." << std::endl;
133 scribo::io::xml::
save(doc, argv[2], scribo::io::xml::Page);
134 std::cout << "End of process - " << t << std::endl;
136 scribo::io::img::
save(doc, mln::debug::
filename("debug_wo_image.png"),
137 scribo::io::img::DebugWoImage);
138 scribo::io::img::
save(doc, mln::debug::
filename("debug_with_image.png"),
139 scribo::io::img::DebugWithImage);