885: Update : erosion (bring some error to light).

I had some probleme with neighborhood image initialisation from another image_with_nbh. See erosion.hh and apply.hh Index: ChangeLog from Ugo Jardonnet <ugo.jardonnet@lrde.epita.fr> Update : erosion (bring some error to light). * oln/morpho, * oln/morpho/dilation.hh: New. * oln/morpho/dilatation.hh: Remove. * oln/morpho/erosion.hh: . * oln/function/min.hh: . * oln/level/apply.hh: . * oln/level/local.hh: . * oln/core/concept/functions.hh: . * oln/core/internal/op_image_plus_nbh.hh: . * oln/morphomath, * oln/morphomath/dilatation.hh, * oln/morphomath/erosion.hh: Remove. core/concept/functions.hh | 5 +++++ core/internal/op_image_plus_nbh.hh | 1 + function/min.hh | 2 +- level/apply.hh | 12 +++++++----- level/local.hh | 18 +++++++++--------- morpho/dilation.hh | 29 +++++++++++++++++++++++++++++ morpho/erosion.hh | 12 +++++++++--- 7 files changed, 61 insertions(+), 18 deletions(-) Index: oln/morpho/dilation.hh --- oln/morpho/dilation.hh (revision 0) +++ oln/morpho/dilation.hh (revision 0) @@ -0,0 +1,29 @@ +#ifndef OLN_MORPHOMATH_DILATATION_HH_ +# define OLN_MORPHOMATH_DILATATION_HH_ + +// Facade. + +namespace impl +{ + + /// Generic version + + template <typename I, typename W> + I dilatation(const Image<I>& input) + { + max_<oln_value(I)> max; + return apply(max, input); + } + +} + + +/// Facade. + +template <typename I, typename W> +I erosion(const Image<I>& input) +{ + return impl::dilatation(exact(input)); +} + +#endif /* !OLN_MORPHOMATH_DILATATION_HH_ */ Index: oln/morpho/erosion.hh --- oln/morpho/erosion.hh (revision 884) +++ oln/morpho/erosion.hh (working copy) @@ -38,16 +38,20 @@ namespace morpho { + template <typename I> + I erosion(const Image_with_Nbh<I>& input); + +# ifndef OLN_INCLUDE_ONLY + namespace impl { /// Generic version template <typename I> - I erosion(Image_with_Nbh<I>& input) + I erosion(const Image_with_Nbh<I>& input) { function::min_<oln_value(I)> min; - return ::oln::level::apply_local(min, input); } } @@ -55,11 +59,13 @@ // Facade. template <typename I> - I erosion(Image_with_Nbh<I>& input) + I erosion(const Image_with_Nbh<I>& input) { return impl::erosion(exact(input)); } +#endif // ! OLN_INCLUDE_ONLY + } // end of namespace } Index: oln/function/min.hh --- oln/function/min.hh (revision 884) +++ oln/function/min.hh (working copy) @@ -46,7 +46,7 @@ min_() { this->init(); } - void init() { val_ = oln_max(T); } + void init() const { val_ = oln_max(T); } result value() const { return val_; } template <typename U> Index: oln/level/apply.hh --- oln/level/apply.hh (revision 884) +++ oln/level/apply.hh (working copy) @@ -85,17 +85,19 @@ /// apply_local template <typename F, typename I> - oln_plain_value(I, typename F::result) - apply_local(const Accumulator<F>& fun, + I apply_local(const Accumulator<F>& f, const Image_with_Nbh<I>& input) { typedef typename F::result result; typedef typename F::argument argument; - oln_ch_value(I, argument) output(input.points()); + typename I::delegatee out(input.points()); + I output(out, input.nbhood()); + // I output(exact(input).image(), input.nbhood()); + // FIXME: init(output, with, input); oln_piter(I) p(input.points()); for_all(p) - output(p) = local(fun, input, p); + output(p) = level::local(f, input, p); return output; } @@ -168,7 +170,7 @@ apply_local(const Accumulator<F>& fun, const Image_with_Nbh<I>& input) { - return impl::apply_local(fun, exact(input)); + return impl::apply_local(fun, input); } // /// Facade. Index: oln/level/local.hh --- oln/level/local.hh (revision 884) +++ oln/level/local.hh (working copy) @@ -5,8 +5,8 @@ // of the GNU General Public License version 2 as published by the // Free Software Foundation. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // @@ -42,7 +42,7 @@ { template <typename A, typename I> - typename A::result + int //typename A::result local(const Accumulator<A>& f, const Image_with_Nbh<I>& input, const oln_point(I)& p); @@ -62,8 +62,8 @@ /// Local Apply on neighborhood (nbh included in image). template <typename A, typename I> - typename A::result - local(const Accumulator<A>& f, + int//typename A::result + local_(const A& f, const Image_with_Nbh<I>& input, const oln_point(I)& p) { @@ -88,7 +88,7 @@ template <typename F, typename I, typename W> typename F::result - local(const Accumulator<F>& f, + local_(const F& f, const Image<I>& input, const oln_point(I)& p, const Window<W>& win) @@ -106,12 +106,12 @@ /// Facades. template <typename A, typename I> - typename A::result + int//typename A::result local(const Accumulator<A>& f, const Image_with_Nbh<I>& input, const oln_point( I )& p) { - return impl::local(f, input, p); + return impl::local_(exact(f), input, p); } template <typename F, typename I, typename W> @@ -121,7 +121,7 @@ const oln_point(I)& p, const Window<W>& win) { - return impl::local(f, input, p, win); + return impl::local_(exact(f), input, p, win); } #endif // ! OLN_INCLUDE_ONLY Index: oln/core/concept/functions.hh --- oln/core/concept/functions.hh (revision 884) +++ oln/core/concept/functions.hh (working copy) @@ -165,6 +165,11 @@ { } + template <typename Exact> + Accumulator<Exact>::Accumulator() + { + } + # endif // OLN_INCLUDE_ONLY } // end of namespace oln Index: oln/core/internal/op_image_plus_nbh.hh --- oln/core/internal/op_image_plus_nbh.hh (revision 884) +++ oln/core/internal/op_image_plus_nbh.hh (working copy) @@ -97,6 +97,7 @@ const delegatee& impl_image() const; nbh impl_nbhood() const; + nbh& impl_nbhood(); protected: special_op_();
participants (1)
-
Ugo Jardonnet