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 trace::entering(
"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);
134 trace::exiting("morpho::impl::generic::general_on_function");
140 template <typename Op, typename I, typename W>
143 general_on_set(const Op& op, const Image<I>& input, const Window<W>& win)
145 trace::entering(
"morpho::impl::generic::general_on_set");
147 internal::general_tests(op, input, win);
150 mln_concrete(I) output;
151 output = accu::transform_stop(input, op.accu(input), win);
153 trace::exiting("morpho::impl::generic::general_on_set");
165 template <typename Op, typename I, typename W>
170 trace::entering(
"morpho::general");
171 mln_precondition(exact(input).is_valid());
172 mln_precondition(! exact(win).is_empty());
174 internal::general_tests(op, input, win);
175 mln_concrete(I) output = internal::general_dispatch(op, input, win);
177 trace::exiting(
"morpho::general");
181 # endif // ! MLN_INCLUDE_ONLY
188 #endif // ! MLN_MORPHO_GENERAL_HH