26 #ifndef MLN_MORPHO_ELEMENTARY_GRADIENT_INTERNAL_HH
27 # define MLN_MORPHO_ELEMENTARY_GRADIENT_INTERNAL_HH
33 # include <mln/morpho/elementary/like_ero_fun.hh>
34 # include <mln/morpho/elementary/like_ero_set.hh>
47 template <
typename I,
typename N>
49 gradient_internal(const Image<I>& input, const Neighborhood<N>& nbh);
52 # ifndef MLN_INCLUDE_ONLY
59 template <
typename V,
typename A>
60 V operator()(
const V& input_p,
const A& a)
const
62 return input_p - a.to_result();
68 template <
typename I,
typename N>
70 gradient_internal_dispatch(trait::image::kind::any,
71 const Image<I>& input, const Neighborhood<N>& nbh)
73 return like_ero_fun(accu::meta::stat::min(), f_grad_int(), input, nbh);
76 template <
typename I,
typename N>
78 gradient_internal_dispatch(trait::image::kind::logic,
79 const Image<I>& input, const Neighborhood<N>& nbh)
89 return like_ero_set(val, input, nbh);
92 template <
typename I,
typename N>
94 gradient_internal_dispatch(const Image<I>& input, const Neighborhood<N>& nbh)
96 return gradient_internal_dispatch(mln_trait_image_kind(I)(),
105 template <
typename I,
typename N>
107 gradient_internal(const Image<I>& input, const Neighborhood<N>& nbh)
109 trace::entering(
"morpho::elementary::gradient_internal");
111 mln_precondition(exact(input).is_valid());
112 mln_precondition(exact(nbh).is_valid());
114 mln_concrete(I) output = internal::gradient_internal_dispatch(input, nbh);
116 mln_postcondition(output <= input);
117 trace::exiting("morpho::elementary::gradient_internal");
121 # endif // ! MLN_INCLUDE_ONLY
130 #endif // ! MLN_MORPHO_ELEMENTARY_GRADIENT_INTERNAL_HH