26 #ifndef MLN_MORPHO_GENERAL_HH
27 # define MLN_MORPHO_GENERAL_HH
36 # include <mln/core/concept/image.hh>
37 # include <mln/core/concept/window.hh>
38 # include <mln/core/concept/neighborhood.hh>
40 # include <mln/extension/adjust_fill.hh>
41 # include <mln/accu/transform.hh>
44 # include <mln/morpho/general.spe.hh>
47 # define mln_morpho_select_accu(I, S, F) \
48 typename mln::metal::if_< mln::metal::is< mln_trait_image_kind(I), \
49 trait::image::kind::binary >, \
51 mln::accu::meta::F >::ret
61 template <
typename Op,
typename I,
typename W>
63 general(const Op& op, const Image<I>& input, const Window<W>&
win);
66 # ifndef MLN_INCLUDE_ONLY
72 template <
typename Op,
typename I,
typename W>
75 general_tests(
const Op& op,
const Image<I>& input_,
const Window<W>& win_)
77 const I& input =
exact(input_);
78 const W& win =
exact(win_);
80 mln_precondition(input.is_valid());
81 mln_precondition(! win.is_empty());
82 mln_precondition(win.is_valid());
91 template <
typename I,
bool is_binary>
94 static mln_value(I) infimum() {
return false; }
95 static mln_value(I) supremum() {
return true; }
98 struct neutral_impl< I, false >
100 static mln_value(I) infimum() {
return mln_min(mln_value(I)); }
101 static mln_value(I) supremum() {
return mln_max(mln_value(I)); }
103 template <
typename I>
104 struct neutral : neutral_impl< I, mlc_is(mln_trait_image_kind(I),
105 trait::image::kind::binary)::value >
121 template <
typename Op,
typename I,
typename W>
124 general_on_function(const Op& op, const Image<I>& input, const Window<W>& win)
126 mln_trace(
"morpho::impl::generic::general_on_function");
128 internal::general_tests(op, input, win);
131 mln_concrete(I) output;
132 output = accu::
transform(input, op.accu(input), win);
139 template <typename Op, typename I, typename W>
142 general_on_set(const Op& op, const Image<I>& input, const Window<W>& win)
144 mln_trace(
"morpho::impl::generic::general_on_set");
146 internal::general_tests(op, input, win);
149 mln_concrete(I) output;
150 output = accu::transform_stop(input, op.accu(input), win);
163 template <typename Op, typename I, typename W>
166 general(const Op& op, const Image<I>& input, const Window<W>& win)
168 mln_trace(
"morpho::general");
169 mln_precondition(
exact(input).is_valid());
170 mln_precondition(!
exact(win).is_empty());
172 internal::general_tests(op, input, win);
173 mln_concrete(I) output = internal::general_dispatch(op, input, win);
178 # endif // ! MLN_INCLUDE_ONLY
185 #endif // ! MLN_MORPHO_GENERAL_HH