27 #ifndef SCRIBO_FILTER_OBJECTS_THICK_HH
28 # define SCRIBO_FILTER_OBJECTS_THICK_HH
34 # include <mln/core/concept/image.hh>
35 # include <mln/core/concept/neighborhood.hh>
37 # include <mln/util/array.hh>
39 # include <scribo/core/component_set.hh>
40 # include <scribo/primitive/extract/components.hh>
63 template <
typename I,
typename N,
typename V>
69 unsigned max_thickness);
85 unsigned max_thickness);
88 # ifndef MLN_INCLUDE_ONLY
96 struct thick_object_filter
104 thick_object_filter(
const component_set<L>& components,
105 unsigned max_thickness)
106 : components_(components), max_thickness_(max_thickness)
115 bool operator()(
const mln_value(L)& l)
const
117 if (l == literal::zero)
119 return components_(l).bbox().nrows() < max_thickness_
120 && components_(l).bbox().ncols() < max_thickness_;
125 component_set<L> components_;
128 unsigned max_thickness_;
135 template <
typename I,
typename N,
typename V>
141 unsigned max_thickness)
143 mln_trace(
"scribo::filter::objects_thick");
145 const I& input =
exact(input_);
148 mln_precondition(input.is_valid());
149 mln_precondition(nbh.is_valid());
153 component_set<lbl_t> components
154 = primitive::extract::components(input, nbh, nlabels);
156 typedef internal::thick_object_filter<lbl_t> func_t;
157 func_t fv2b(components, max_thickness);
160 mln_concrete(I) output =
duplicate(input);
161 data::
fill((output | pw::
value(components) == literal::zero).rw(), false);
167 template <typename L>
171 unsigned max_thickness)
173 mln_trace(
"scribo::filter::objects_thick");
175 mln_precondition(components.is_valid());
177 typedef internal::thick_object_filter<L> func_t;
178 func_t is_not_too_thick(components, max_thickness);
180 component_set<L> output = components.duplicate();
186 # endif // ! MLN_INCLUDE_ONLY
193 #endif // ! SCRIBO_FILTER_OBJECTS_THICK_HH