Commit 71d0bbc4 by Edwin Carlinet

    * mln/morpho/structural/gradient.hpp: New alg.
 ... ... @@ -51,13 +51,51 @@ namespace mln NormFunction norm = NormFunction ()); template O& void gradient(const Image& input, const StructuringElement& se, Compare cmp, NormFunction norm, Image& out); /// \brief Compute the morphological external gradient. /// /// The beucher external gradient is defined as: /// \f[ /// |\Nabla u(p)| = \left| \bigvee_{q \in \mathcal{N}(p)} f(q) - f(p) \right| /// \f] /// /// \param[in] input Input image. /// \param[in] se Neighborhood/SE/Window to look around. /// \param[in] cmp (optional) Comparaison function. The method internally does an /// unqualified call to inf(x, y, cmp) and sup(x, y, cmp). Default /// is the product-order. /// \param[in] norm (optional) Norm function used in \f$|x - y|\f$. The default is /// the ℓ₂-norm. /// \param[out] out (optional) Output image to write in. /// /// FIXME: This can be done in a single pass using kernels but you /// we have to consider: /// * an incrementable accumlator /// * an extension that is mirrorizable template , class NormFunction = mln::functional::l2norm_t > mln_ch_value(I, typename std::result_of::type) external_gradient(const Image& input, const StructuringElement& se, Compare cmp = Compare (), NormFunction norm = NormFunction ()); template void external_gradient(const Image& input, const StructuringElement& se, Compare cmp, NormFunction norm, Image& out); /*************************/ /*** Implementation ***/ /*************************/ ... ... @@ -76,10 +114,21 @@ namespace mln transform(d-e, norm, out); } // Version non-fast dilate - erode template void external_gradient(const I& ima, const SE& nbh, Compare cmp, Norm norm, J& out) { auto d = morpho::structural::dilate(ima, nbh, cmp); transform(d-ima, norm, out); } } template O& void gradient(const Image& ima_, const StructuringElement& se_, Compare cmp, ... ... @@ -94,7 +143,6 @@ namespace mln mln::morpho::structural::impl::gradient(ima, se, cmp, norm, out); mln::trace::exiting(); return out; } ... ... @@ -115,6 +163,43 @@ namespace mln return out; } template void external_gradient(const Image& ima_, const StructuringElement& se_, Compare cmp, Norm norm, Image& output) { mln::trace::entering("mln::morpho::external_gradient"); const I& ima = exact(ima_); const SE& se = exact(se_); O& out = exact(output); mln::morpho::structural::impl::external_gradient(ima, se, cmp, norm, out); mln::trace::exiting(); } template mln_ch_value(I, typename std::result_of::type) external_gradient(const Image& ima_, const StructuringElement& se, Compare cmp, Norm norm) { const I& ima = exact(ima_); typedef mln_value(I) V; typedef typename std::result_of::type result_type; mln_ch_value(I, result_type) out = imchvalue (ima); mln::morpho::structural::external_gradient(ima, se, cmp, norm, out); return out; } } } ... ...