27 #ifndef SCRIBO_FILTER_COMPONENTS_THIN_HH
28 # define SCRIBO_FILTER_COMPONENTS_THIN_HH
34 # include <mln/core/concept/image.hh>
35 # include <mln/core/concept/neighborhood.hh>
36 # include <mln/core/image/dmorph/image_if.hh>
37 # include <mln/pw/all.hh>
39 # include <mln/util/array.hh>
41 # include <mln/data/transform.hh>
43 # include <scribo/core/component_set.hh>
44 # include <scribo/primitive/extract/components.hh>
45 # include <scribo/filter/internal/compute.hh>
66 template <
typename I,
typename N,
typename V>
72 unsigned min_thickness);
88 unsigned min_thickness);
91 # ifndef MLN_INCLUDE_ONLY
100 struct components_thin_filter
107 components_thin_filter(
const component_set<L>& components,
108 unsigned min_thickness)
109 : components_(components), min_thickness_(min_thickness)
118 bool operator()(
const mln_value(L)& l)
const
120 if (l == literal::zero)
122 return components_(l).bbox().nrows() > min_thickness_
123 && components_(l).bbox().ncols() > min_thickness_;
127 component_set<L> components_;
130 unsigned min_thickness_;
137 template <
typename I,
typename N,
typename V>
143 unsigned min_thickness)
145 mln_trace(
"scribo::filter::components_thin");
147 const I& input =
exact(input_);
150 mln_precondition(input.is_valid());
151 mln_precondition(nbh.is_valid());
156 component_set<lbl_t> comps
157 = primitive::extract::components(input, nbh, nlabels);
159 typedef internal::components_thin_filter<lbl_t> func_t;
160 func_t fv2b(comps, min_thickness);
168 template <typename L>
172 unsigned min_thickness)
174 mln_trace(
"scribo::filter::components_thin");
176 mln_precondition(components.is_valid());
178 typedef internal::components_thin_filter<L> func_t;
179 func_t is_not_too_thin(components, min_thickness);
181 component_set<L> output = components.duplicate();
187 # endif // ! MLN_INCLUDE_ONLY
194 #endif // ! SCRIBO_FILTER_COMPONENTS_THIN_HH