32 #include <mln/core/image/image2d.hh>
34 #include <mln/io/magick/load.hh>
36 #include <scribo/toolchain/content_in_hdoc.hh>
37 #include <scribo/toolchain/text_in_doc_preprocess.hh>
39 #include <scribo/core/document.hh>
41 #include <scribo/debug/usage.hh>
42 #include <scribo/debug/logger.hh>
44 #include <scribo/preprocessing/crop_without_localization.hh>
45 #include <scribo/preprocessing/crop.hh>
47 #include <scribo/io/xml/save.hh>
48 #include <scribo/io/img/save.hh>
51 #include <mln/core/alias/neighb2d.hh>
52 #include <mln/labeling/compute.hh>
53 #include <mln/labeling/foreground.hh>
54 #include <mln/util/timer.hh>
58 const char *args_desc[][2] =
60 {
"input.tif",
"An image." },
61 {
"out.xml",
"Result of the document analysis (PAGE format)." },
67 int main(
int argc,
char* argv[])
69 using namespace scribo;
74 "Document Image Analysis in Historical Books"
75 " for Historical Book Recognition Contest 2013",
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;