26 #ifndef SCRIBO_POSTPROCESSING_IMAGES_TO_DROP_CAPITAL_HH
27 # define SCRIBO_POSTPROCESSING_IMAGES_TO_DROP_CAPITAL_HH
35 # include <mln/core/concept/image.hh>
36 # include <mln/draw/box_plain.hh>
37 # include <scribo/core/component_set.hh>
38 # include <scribo/core/document.hh>
44 namespace postprocessing
60 # ifndef MLN_INCLUDE_ONLY
66 mln_trace(
"scribo::postprocessing::images_to_drop_capital");
68 mln_precondition(doc.is_valid());
70 if (! doc.has_elements())
74 initialize(billboard, doc.image());
77 for_all_comps(p, doc.paragraphs())
78 if (doc.paragraphs()(p).is_valid())
79 mln::draw::
box_plain(billboard, doc.paragraphs()(p).
bbox(), true);
81 float min_img_size = 0.2 * (doc.image().domain().width()
82 + doc.image().domain().
height());
84 component_set<L> elts = doc.elements();
85 for_all_comps(c, elts)
86 if (elts(c).is_valid() && elts(c).type() == component::
Image)
88 const mln_box(L)& b_ = elts(c).bbox();
90 const bool tl = billboard(b_.pmin());
91 const bool tr = billboard.at_(b_.pmin().row(), b_.pmax().col());
92 const bool mb = billboard.at_(b_.pmax().row(), b_.pcenter().col());
93 const bool mc = billboard.at_(b_.pcenter().row(), b_.pcenter().col());
94 const bool mr = billboard.at_(b_.pcenter().row(), b_.pmax().col());
95 const bool bl = billboard.at_(b_.pmax().row(), b_.pmin().col());
96 const bool br = billboard(b_.pmax());
108 if (s.nelements() > 2 || (s.nelements() == 2 && !s.has(0)))
111 float elt_size = elts(c).bbox().width() + elts(c).bbox().height();
112 for_all_elements(e, s)
114 && (mc != 0 && mc == s[e]
115 && ((tl == mc && bl == mc)
116 || (tr == mc && br == mc)
117 || (bl == mc && br == mc)
118 || (tl == mc && tr == mc)
119 || (br == mc && mr == mc && mb == mc)))
120 && (elt_size < min_img_size))
129 doc.set_elements(elts);
133 # endif // ! MLN_INCLUDE_ONLY
139 #endif // ! SCRIBO_POSTPROCESSING_IMAGES_TO_DROP_CAPITAL_HH