26 #ifndef SCRIBO_FILTER_PARAGRAPHS_IN_IMAGE_HH
27 # define SCRIBO_FILTER_PARAGRAPHS_IN_IMAGE_HH
35 # include <mln/core/concept/image.hh>
36 # include <mln/core/concept/neighborhood.hh>
37 # include <mln/core/concept/function.hh>
38 # include <mln/core/image/dmorph/image_if.hh>
40 # include <mln/data/transform.hh>
41 # include <mln/draw/box_plain.hh>
43 # include <mln/util/array.hh>
45 # include <mln/pw/all.hh>
47 # include <scribo/core/document.hh>
48 # include <scribo/core/paragraph_set.hh>
49 # include <scribo/fun/v2b/objects_small_filter.hh>
50 # include <scribo/primitive/extract/components.hh>
76 # ifndef MLN_INCLUDE_ONLY
82 mln_trace(
"scribo::filter::paragraphs_in_image");
84 mln_precondition(doc.has_elements());
85 mln_precondition(doc.has_text());
88 initialize(billboard, doc.lines().components().labeled_image());
92 for_all_elements(e, doc.elements())
93 if (doc.elements()(e).is_valid()
97 const paragraph_set<L>& parset = doc.paragraphs();
99 not_to_ignore(0) =
false;
101 for_all_paragraphs(cur_id, parset)
105 tl = billboard(b_.
pmin()),
109 br = billboard(b_.
pmax());
119 if (s.nelements() > 2 || (s.nelements() == 2 && !s.has(0)))
123 for_all_elements(e, s)
125 && (mc != 0 && mc == s[e]
126 && ((tl == mc && bl == mc)
127 || (tr == mc && br == mc)
128 || (tl == mc && tr == mc)
129 || (bl == mc && br == mc))))
132 not_to_ignore(cur_id) =
false;
137 paragraph_set<L> output = parset.duplicate();
138 output.invalidate(not_to_ignore);
139 doc.set_paragraphs(output);
144 # endif // ! MLN_INCLUDE_ONLY
150 #endif // ! SCRIBO_FILTER_PARAGRAPHS_IN_IMAGE_HH