
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox Index: ChangeLog from Alexandre Abraham <abraham@lrde.epita.fr> INIM : nature filters and little bug fixes. * abraham/mln/trait: New. * abraham/mln/trait/images.hh: New (mln::trait::default_image_morpher) : Adjust quant according to new value quant.. * abraham/mln/morpho/hit_or_miss.hh: New (mln::morpho::hit_or_miss) : First implementation of hit or miss algorithm. * abraham/mln/level/transform.hh: New (mln::level::transform) : Add procedure. * abraham/mln/core/image/thru.hh: Temporary trait modification. * abraham/mln/core/image/shell.hh: Add include of function.hh. * abraham/mln/fun/meta/hue.hh: New Allow direct access to hue. * abraham/mln/fun/meta/inty.hh: New Allow direct access to intensity.. * abraham/mln/fun/meta/sat.hh: New Allow direct access to saturation.. * abraham/mln/fun/v2v: New. * abraham/mln/fun/v2v/rgb_to_hsi.hh: New Fix wrong conversion formula. * abraham/mln/binarization: New. * abraham/mln/binarization/binarization.hh: New Fix call to level::transform procedure (output must be empty). * abraham/mln/value: New. * abraham/mln/value/builtin: New. * abraham/mln/value/builtin/symbolics.hh: New Add min and max for bool traits. * nature/erosion.cc: New Test of erosion filter. * nature/gradient.cc: New Test of gradient filter. * nature/histo_hsi.cc: New Decompose image in hsi format. * nature/hom.cc: New First hit or miss test. * nature/opening.cc: New Test of opening filter. * nature/Makefile: New. abraham/mln/binarization/binarization.hh | 106 +++++++++++++ abraham/mln/core/image/shell.hh | 1 abraham/mln/core/image/thru.hh | 14 + abraham/mln/fun/meta/hue.hh | 64 ++++++++ abraham/mln/fun/meta/inty.hh | 64 ++++++++ abraham/mln/fun/meta/sat.hh | 64 ++++++++ abraham/mln/fun/v2v/rgb_to_hsi.hh | 175 ++++++++++++++++++++++ abraham/mln/level/transform.hh | 209 +++++++++++++++++++++++++++ abraham/mln/morpho/hit_or_miss.hh | 84 ++++++++++ abraham/mln/trait/images.hh | 239 +++++++++++++++++++++++++++++++ abraham/mln/value/builtin/symbolics.hh | 76 +++++++++ nature/Makefile | 16 ++ nature/erosion.cc | 59 +++++++ nature/gradient.cc | 59 +++++++ nature/histo_hsi.cc | 166 +++++++++++++++++++++ nature/hom.cc | 72 +++++++++ nature/opening.cc | 59 +++++++ 17 files changed, 1527 insertions(+) Index: abraham/mln/trait/images.hh --- abraham/mln/trait/images.hh (revision 0) +++ abraham/mln/trait/images.hh (revision 0) @@ -0,0 +1,239 @@ +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// 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 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +#ifndef MLN_TRAIT_IMAGES_HH +# define MLN_TRAIT_IMAGES_HH + +/*! \file mln/trait/images.hh + * + * \brief Some base trait types for images. + * + * \todo Split this file into many. + * + * \todo the 'nature' prop is not set yet in image types. + */ + +# include <iostream> +# include <string> + +# include <mln/trait/undef.hh> +# include <mln/trait/image/props.hh> +# include <mln/trait/value_.hh> + +# include <mln/metal/bexpr.hh> +# include <mln/metal/equal.hh> +# include <mln/metal/if.hh> +# include <mln/metal/is_const.hh> + + + +# define mln_trait_image_category(I) typename mln::trait::image_< I >::category +# define mln_trait_image_speed(I) typename mln::trait::image_< I >::speed +# define mln_trait_image_size(I) typename mln::trait::image_< I >::size + +# define mln_trait_image_value_access(I) typename mln::trait::image_< I >::value_access +# define mln_trait_image_value_storage(I) typename mln::trait::image_< I >::value_storage +# define mln_trait_image_value_browsing(I) typename mln::trait::image_< I >::value_browsing +# define mln_trait_image_value_io(I) typename mln::trait::image_< I >::value_io +# define mln_trait_image_pw_io(I) typename mln::trait::image_< I >::pw_io +# define mln_trait_image_vw_io(I) typename mln::trait::image_< I >::vw_io +# define mln_trait_image_vw_set(I) typename mln::trait::image_< I >::vw_set +# define mln_trait_image_value_alignement(I) typename mln::trait::image_< I>::value_alignement + +# define mln_trait_image_localization(I) typename mln::trait::image_< I >::localization +# define mln_trait_image_dimension(I) typename mln::trait::image_< I >::dimension + +# define mln_trait_image_ext_domain(I) typename mln::trait::image_< I >::ext_domain +# define mln_trait_image_ext_value(I) typename mln::trait::image_< I >::ext_value +# define mln_trait_image_ext_io(I) typename mln::trait::image_< I >::ext_io + +# define mln_trait_image_kind(I) typename mln::trait::image_< I >::kind +# define mln_trait_image_nature(I) typename mln::trait::image_< I >::nature +# define mln_trait_image_quant(I) typename mln::trait::image_< I >::quant + + +// For value_io: I const => read_only, otherwise like I + +# define mln_internal_trait_image_value_io_from(I) \ + \ + mlc_if( mlc_is_const(I), \ + mln::trait::image::value_io::read_only, \ + mln_trait_image_value_io(I) ) + + +# define mln_internal_trait_image_speed_from(I) \ + \ + mlc_if( mlc_equal( mln_trait_image_speed(I), mln::trait::image::speed::fastest ), \ + mln::trait::image::speed::fast, \ + mln_trait_image_speed(I) ) + + + +namespace mln +{ + + // Primitive types. + template <typename T> struct image1d; + template <typename T> struct image2d; + template <typename T> struct image3d; + namespace pw { template <typename F, typename S> struct image; } + template <typename P, typename T> class rle_image; + template <typename P, typename T> class sparse_image; + + // Morphers. + template <typename I, typename F> struct image_if_base; + template <typename I, typename D> class decorated_image; + template <typename I, typename S> class sub_image; + template <typename I> struct t_image; + template <typename I> class safe_image; + template <typename T, typename I> class cast_image_; + namespace value { template <unsigned n, typename I> struct stack_image; } + + + namespace trait + { + + template <typename I> + struct undefined_image_ + { + // misc + typedef undef category; + typedef undef speed; + typedef undef size; + + // value + typedef undef vw_io; + typedef undef vw_set; + typedef undef value_alignement; + typedef undef value_access; + typedef undef value_storage; + typedef undef value_browsing; + typedef undef value_io; + + // site + typedef undef pw_io; + typedef undef localization; + typedef undef dimension; + + // extended domain + typedef undef ext_domain; + typedef undef ext_value; + typedef undef ext_io; + + // data (I::value) + typedef undef kind; + typedef undef nature; + typedef undef quant; + }; + + + template <typename I> + struct image_ : undefined_image_<I> + { + }; + + + template <typename I> + struct image_<const I> : image_<I> + { + // FIXME: TODO: io cannot contain "write"... + }; + + + template <typename T, typename I> + struct default_image_ : undefined_image_<I> + { + private: + typedef mlc_equal(mln_trait_value_quant(T), + trait::value::quant::high) is_high_quant_; + public: + typedef mln_trait_value_kind(T) kind; + typedef mlc_if( is_high_quant_, + trait::image::quant::high, + trait::image::quant::low ) quant; + // FIXME: typedef undef value; // scalar, vectorial, structed + + // speed is fast by default (neither "fastest" nor "slow") + typedef trait::image::speed::fast speed; + }; + + + template <typename D, typename T, typename I> + struct default_image_morpher : default_image_<T, I> + { + // misc => delegation except for 'category' + typedef typename image_<D>::size size; + typedef mln_internal_trait_image_speed_from(D) speed; // un-fastest + + // value => delegation + typedef typename image_<D>::vw_io vw_io; + typedef typename image_<D>::vw_set vw_set; + typedef typename image_<D>::value_alignement value_alignement; + typedef typename image_<D>::value_access value_access; + typedef typename image_<D>::value_storage value_storage; + typedef typename image_<D>::value_browsing value_browsing; + typedef mln_internal_trait_image_value_io_from(D) value_io; // un-write when D is const + + // site => delegation + typedef typename image_<D>::pw_io pw_io; + typedef typename image_<D>::localization localization; + typedef typename image_<D>::dimension dimension; + + // extended domain => delegation + typedef typename image_<D>::ext_domain ext_domain; + typedef typename image_<D>::ext_value ext_value; + typedef typename image_<D>::ext_io ext_io; + + // data (I::value) => delegation + typedef typename image_<D>::nature nature; + typedef typename image_<D>::kind kind; + // typedef typename image_<D>::quant quant; + typedef + mlc_if(mlc_equal(typename value_<T>::quant, trait::value::quant::low), + // Then + trait::image::quant::low, + // Else + mlc_if(mlc_equal(typename value_<T>::quant, trait::value::quant::high), + // Then + trait::image::quant::high, + // Else + undef) + ) + quant; + + }; + + + } // end of namespace mln::trait + +} // end of namespace mln + + +# include <mln/trait/image/print.hh> + + +#endif // ! MLN_TRAIT_IMAGES_HH Index: abraham/mln/morpho/hit_or_miss.hh --- abraham/mln/morpho/hit_or_miss.hh (revision 0) +++ abraham/mln/morpho/hit_or_miss.hh (revision 0) @@ -0,0 +1,84 @@ +// Copyright (C) 2007 EPITA Research and Development Laboratory +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// 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 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +#ifndef MLN_MORPHO_HIT_OR_MISS_HH +# define MLN_MORPHO_HIT_OR_MISS_HH + +/*! \file mln/morpho/hit_or_miss.hh + * + * \brief Morphological gradient. + * + * \todo Save memory. + */ + +# include <mln/morpho/includes.hh> +# include <mln/arith/revert.hh> + +namespace mln +{ + + namespace morpho + { + + /*! Morphological hit or miss. + * + */ + template <typename I, typename Wout, typename Win> + mln_concrete(I) hit_or_miss(const Image<I>& input, const Window<Wout>& win_out, const Window<Win>& win_in); + + + // FIXME : epaississement et amincissement + + +# ifndef MLN_INCLUDE_ONLY + + template <typename I, typename Wout, typename Win> + inline + mln_concrete(I) hit_or_miss(const Image<I>& input, const Window<Wout>& win_out, const Window<Win>& win_in) + { + trace::entering("morpho::hit_or_miss"); + mln_precondition(exact(input).has_data()); + mln_precondition(! exact(win_out).is_empty()); + mln_precondition(! exact(win_in).is_empty()); + + mln_concrete(I) output = morpho::min(erosion(arith::revert(input), win_out), + erosion(input, win_in)); + + mln_postcondition(test::positive(output)); + trace::exiting("morpho::hit_or_miss"); + return output; + } + + +# endif // ! MLN_INCLUDE_ONLY + + } // end of namespace mln::morpho + +} // end of namespace mln + + +#endif // ! MLN_MORPHO_HIT_OR_MISS_HH Index: abraham/mln/level/transform.hh --- abraham/mln/level/transform.hh (revision 0) +++ abraham/mln/level/transform.hh (revision 0) @@ -0,0 +1,209 @@ +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// 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 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + // General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +#ifndef MLN_LEVEL_TRANSFORM_HH +# define MLN_LEVEL_TRANSFORM_HH + +/*! \file mln/level/transform.hh + * + * \brief Transform the contents of an image into another one. + * + * \todo Clean this file + overload with pixel iterators. + * + * \todo Re-activate tests and make them static. + */ + +# include <mln/core/concept/image.hh> +# include <mln/core/concept/function.hh> + +# include <mln/value/set.hh> +# include <mln/value/lut_vec.hh> + + +// Specializations are in: +# include <mln/level/transform.spe.hh> + + +namespace mln +{ + + namespace level + { + + /*! Transform the image \p input through a function \p f to set + * the \p output image. + * + * \param[in] input The input image. + * \param[in] f The function. + * \param[out] output The result image. + * + * This routine runs: \n + * for all p of \p input, \p output(p) = \p f( \p input(p) ). + * + * \pre \p output.domain >= \p input.domain + */ + template <typename I, typename F, typename O> + void transform(const Image<I>& input, const Function_v2v<F>& f, + Image<O>& output); + + + template <typename I, typename F> + mln_ch_value(I, mln_result(F)) + transform(const Image<I>& input, const Function_v2v<F>& f); + + +# ifndef MLN_INCLUDE_ONLY + + namespace internal + { + template <typename I, typename F, typename O> + inline + void transform_tests(const Image<I>& input, + const Function_v2v<F>& f, + Image<O>& output) + { + // Avoid a warning about an undefined variable when NDEBUG + // is not defined. + (void) input; + (void) f; + (void) output; + + // Properties check + // FIXME: Re-activate! +// mln_precondition((mlc_is(mln_trait_image_pw_io(O), +// trait::image::pw_io::read_write)::value || +// mlc_is(mln_trait_image_vw_io(O), +// trait::image::vw_io::read_write)::value)); + + // FIXME Convert test + mlc_converts_to(mln_result(F), mln_value(O))::check(); + + + // Dynamic tests + mln_precondition(exact(input).has_data()); + mln_precondition(exact(output).domain() >= exact(input).domain()); + } + } // end of namespace mln::level::internal + + + namespace impl + { + + + namespace generic + { + + // Generic implementation. + template <typename I, typename F, typename O> + inline + void transform(const Image<I>& input_, const Function_v2v<F>& f_, + Image<O>& output_) + { + trace::entering("level::impl::generic::transform"); + + + const I& input = exact(input_); + const F& f = exact(f_); + O& output = exact(output_); + + level::internal::transform_tests(input, f, output); + + mlc_is(mln_trait_image_pw_io(O), + trait::image::pw_io::read_write)::check(); + + mln_piter(I) p(input.domain()); + for_all(p) + output(p) = f(input(p)); + + + trace::exiting("level::impl::generic::transform"); + } + + } // end of namespace mln::level::impl::generic + + + + // Facade. + + namespace internal + { + template <typename I, typename F, typename O> + inline + void transform_(const Image<I>& input, const Function_v2v<F>& f, + Image<O>& output) + { + trace::entering("level::transform"); + + mln_precondition(exact(output).domain() >= exact(input).domain()); + transform_dispatch_(exact(input), exact(f), exact(output)); + + trace::exiting("level::transform"); + } + } + + } // end of namespace mln::level::impl + + template <typename I, typename F, typename O> + inline + void transform(const Image<I>& input, const Function_v2v<F>& f, + Image<O>& output) + { + trace::entering("level::transform"); + + mln_precondition(exact(input).has_data()); + initialize(output, input); + impl::internal::transform_(input, f, output); + + trace::exiting("level::transform"); + } + + + template <typename I, typename F> + inline + mln_ch_value(I, mln_result(F)) + transform(const Image<I>& input, const Function_v2v<F>& f) + { + trace::entering("level::transform"); + + mln_precondition(exact(input).has_data()); + mln_ch_value(I, mln_result(F)) output; + initialize(output, input); + impl::internal::transform_(input, f, output); + + trace::exiting("level::transform"); + return output; + } + + +# endif // ! MLN_INCLUDE_ONLY + + } // end of namespace mln::level + +} // end of namespace mln + + +#endif // ! MLN_LEVEL_TRANSFORM_HH Index: abraham/mln/core/image/thru.hh --- abraham/mln/core/image/thru.hh (revision 2721) +++ abraham/mln/core/image/thru.hh (working copy) @@ -39,6 +39,8 @@ # include <mln/trait/images.hh> # include <mln/value/set.hh> # include <mln/core/image/shell.hh> +# include <mln/metal/if.hh> +# include <mln/metal/equal.hh> namespace mln { @@ -69,6 +71,18 @@ typedef trait::image::value_io::read_write value_io; typedef trait::image::value_access::computed value_access; typedef trait::image::value_storage::disrupted value_storage; + typedef + mlc_if(mlc_equal(typename value_<mln_result(F)>::quant, trait::value::quant::low), + // Then + trait::image::quant::low, + // Else + mlc_if(mlc_equal(typename value_<mln_result(F)>::quant, trait::value::quant::high), + // Then + trait::image::quant::high, + // Else + undef) + ) + quant; }; } // end of namespace mln::trait Index: abraham/mln/core/image/shell.hh --- abraham/mln/core/image/shell.hh (revision 2721) +++ abraham/mln/core/image/shell.hh (working copy) @@ -28,6 +28,7 @@ #ifndef MLN_CORE_VALUE_SHELL_HH # define MLN_CORE_VALUE_SHELL_HH +# include <mln/core/concept/function.hh> # include <mln/core/concept/image.hh> namespace mln Index: abraham/mln/fun/meta/hue.hh --- abraham/mln/fun/meta/hue.hh (revision 0) +++ abraham/mln/fun/meta/hue.hh (revision 0) @@ -0,0 +1,64 @@ +// Copyright (C) 2007 EPITA Research and Development Laboratory +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// 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 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +#ifndef MLN_FUN_META_HUE_HH +# define MLN_FUN_META_HUE_HH + +# include <mln/value/hsi.hh> +# include <mln/core/concept/meta_fun.hh> + +namespace mln { + + namespace meta { + + template <class H> + struct hue : impl< hue<H> > { typedef H value; }; + + }; + + template <class H, class S, class I> + struct function< meta::hue< value::hsi_<H, S, I> > > : public Function_v2w_w2v<function< meta::hue < value::hsi_<H, S, I> > > > + { + typedef value::hsi_<H, S, I> value; + + typedef H result; + H read(const value& h) + { + return h.hue(); + } + + typedef H& lresult; + H& write(value& h) + { + return h.hue(); + } + }; + + +}; + +#endif // MLN_FUN_META_HUE_HH Index: abraham/mln/fun/meta/inty.hh --- abraham/mln/fun/meta/inty.hh (revision 0) +++ abraham/mln/fun/meta/inty.hh (revision 0) @@ -0,0 +1,64 @@ +// Copyright (C) 2007 EPITA Research and Development Laboratory +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// 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 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +#ifndef MLN_FUN_META_INTY_HH +# define MLN_FUN_META_INTY_HH + +# include <mln/value/hsi.hh> +# include <mln/core/concept/meta_fun.hh> + +namespace mln { + + namespace meta { + + template <class H> + struct inty : impl< inty<H> > { typedef H value; }; + + }; + + template <class H, class S, class I> + struct function< meta::inty< value::hsi_<H, S, I> > > : public Function_v2w_w2v<function< meta::inty < value::hsi_<H, S, I> > > > + { + typedef value::hsi_<H, S, I> value; + + typedef H result; + H read(const value& h) + { + return h.inty(); + } + + typedef H& lresult; + H& write(value& h) + { + return h.inty(); + } + }; + + +}; + +#endif // MLN_FUN_META_INTY_HH Index: abraham/mln/fun/meta/sat.hh --- abraham/mln/fun/meta/sat.hh (revision 0) +++ abraham/mln/fun/meta/sat.hh (revision 0) @@ -0,0 +1,64 @@ +// Copyright (C) 2007 EPITA Research and Development Laboratory +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// 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 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +#ifndef MLN_FUN_META_SAT_HH +# define MLN_FUN_META_SAT_HH + +# include <mln/value/hsi.hh> +# include <mln/core/concept/meta_fun.hh> + +namespace mln { + + namespace meta { + + template <class H> + struct sat : impl< sat<H> > { typedef H value; }; + + }; + + template <class H, class S, class I> + struct function< meta::sat< value::hsi_<H, S, I> > > : public Function_v2w_w2v<function< meta::sat < value::hsi_<H, S, I> > > > + { + typedef value::hsi_<H, S, I> value; + + typedef H result; + H read(const value& h) + { + return h.sat(); + } + + typedef H& lresult; + H& write(value& h) + { + return h.sat(); + } + }; + + +}; + +#endif // MLN_FUN_META_SAT_HH Index: abraham/mln/fun/v2v/rgb_to_hsi.hh --- abraham/mln/fun/v2v/rgb_to_hsi.hh (revision 0) +++ abraham/mln/fun/v2v/rgb_to_hsi.hh (revision 0) @@ -0,0 +1,175 @@ +// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// 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 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. +// reasons why the executable file might be covered by the GNU General +// Public License. + +#ifndef MLN_FUN_V2V_RGB_TO_HSI_HH +# define MLN_FUN_V2V_RGB_TO_HSI_HH + +#include <cmath> + +#include <mln/value/rgb8.hh> +#include <mln/math/round.hh> + +#include <mln/value/hsi.hh> + + +// FIXME: Split interface and implementation. + +namespace mln +{ + + + namespace fun + { + + namespace v2v + { + + template <typename T_hsi> + struct f_rgb_to_hsi_ : public Function_v2v< f_rgb_to_hsi_<T_hsi> > + { + typedef T_hsi result; + + template <typename T_rgb> + T_hsi operator()(const T_rgb& rgb) const + { + // Locals. + + // wtf? + +// static const double sqrt3_3 = std::sqrt(3) / 3; +// static const double inv_sqrt6 = 1 / std::sqrt(6); +// static const double inv_sqrt2 = 1 / std::sqrt(2); + + T_hsi hsi; + +// double alpha = inv_sqrt2 * rgb.green() - inv_sqrt2 * rgb.blue(); +// double beta = +// 2 * inv_sqrt6 * rgb.red() - +// inv_sqrt6 * rgb.green() - +// inv_sqrt6 * rgb.blue(); + + +// hsi.hue() = atan2(beta, alpha) / 3.1415 * 180.0; +// if (hsi.hue() < 0) +// hsi.hue() = hsi.hue() + 360.0; +// mln_invariant(hsi.hue() >= 0); +// hsi.sat() = std::sqrt(alpha * alpha + beta * beta); +// hsi.inty() = +// sqrt3_3 * rgb.red() + +// sqrt3_3 * rgb.green() + +// sqrt3_3 * rgb.blue(); + + hsi.inty() = (rgb.red() + rgb.green() + rgb.blue()) / 3; + + typename T_rgb::red_t min = rgb.red(); + if (rgb.green() < min) + min = rgb.green(); + + if (rgb.blue() < min) + min = rgb.blue(); + + + if (hsi.inty()) + hsi.sat() = (1 - (double) 3 * min / (double)(rgb.red() + rgb.green() + rgb.blue())) * 100; + else + hsi.sat() = 0; // this is black for any value of saturation + + if (hsi.sat()) + hsi.hue() = acos( 0.5 * (2 * rgb.red() - rgb.green() - rgb.blue()) / + std::sqrt((rgb.red() - rgb.green()) * (rgb.red() - rgb.green()) + (rgb.red() - rgb.blue()) * (rgb.green() - rgb.blue()))) / 3.1415 * 180.0; + else + hsi.hue() = 0; // this is grey for any value of hue + + if (hsi.hue() < 0) + hsi.hue() = hsi.hue() + 360.0; + + mln_invariant(hsi.hue() >= 0); + mln_invariant(hsi.hue() < 360); + mln_invariant(hsi.sat() >= 0); + mln_invariant(hsi.inty() >= 0); + + return hsi; + } + }; + + typedef f_rgb_to_hsi_<value::hsi_f> f_rgb_to_hsi_f_t; + + // FIXME: Warning: global object. + f_rgb_to_hsi_f_t f_rgb_to_hsi_f; + + + template <typename T_rgb> + struct f_hsi_to_rgb_ : public Function_v2v< f_hsi_to_rgb_<T_rgb> > + { + typedef T_rgb result; + + template <typename T_hsi> + T_rgb operator()(const T_hsi& hsi) const + { + typedef typename T_rgb::red_t red_t; + typedef typename T_rgb::green_t green_t; + typedef typename T_rgb::blue_t blue_t; + + static math::round<red_t> to_r; + static math::round<green_t> to_g; + static math::round<blue_t> to_b; + + static const float + sqrt3_3 = std::sqrt(3) / 3, + inv_sqrt6 = 1 / std::sqrt(6), + inv_sqrt2 = 1 / std::sqrt(2); + + float + h = hsi.hue() / 180.0 * 3.1415, + alpha = hsi.sat() * std::cos(h), + beta = hsi.sat() * std::sin(h); + + + red_t r = to_r(sqrt3_3 * hsi.inty() + 2 * inv_sqrt6 * beta); + green_t g = + to_g(sqrt3_3 * hsi.inty() + inv_sqrt2 * alpha - inv_sqrt6 * beta); + blue_t b = + to_b(sqrt3_3 * hsi.inty() - inv_sqrt2 * alpha - inv_sqrt6 * beta); + + T_rgb rgb(r, g, b); + + return rgb; + } + }; + + typedef f_hsi_to_rgb_<value::rgb8> f_hsi_to_rgb_3x8_t; + + // FIXME: Warning: global object. + f_hsi_to_rgb_3x8_t f_hsi_to_rgb_3x8; + + } // end of namespace fun::v2v + + } // end of namespace fun + +} // end of namespace mln + +#endif // ! MLN_FUN_V2V_RGB_TO_HSI_HH Index: abraham/mln/binarization/binarization.hh --- abraham/mln/binarization/binarization.hh (revision 0) +++ abraham/mln/binarization/binarization.hh (revision 0) @@ -0,0 +1,106 @@ +// Copyright (C) 2008 EPITA Research and Development Laboratory +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// 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 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +#ifndef MLN_BINARIZATION_BINARIZATION_HH +# define MLN_BINARIZATION_BINARIZATION_HH + +/*! \file mln/binarization/threshold.hh + * + * \brief Threshold the contents of an image into another binary one. + */ + +# include <mln/core/concept/function.hh> +# include <mln/level/transform.hh> + + +namespace mln +{ + + namespace binarization + { + + /*! Thresholds the values of \p input so that they can be stored in + * the \p output binary image. + * + * \param[in] input The input image. + * \param[in] fun The thresholding function, from value(I) to bool. + * + * for_all(p), output(p) = fun(p) + * + */ + template <typename I, typename F> + inline + mln_concrete_ch_value(I, bool) + binarization(const Image<I>& input, const Function_v2b<F>& fun); + +# ifndef MLN_INCLUDE_ONLY + + namespace impl + { + + template <typename I, typename F> + inline + mln_concrete_ch_value(I, bool) + binarization_(const I& input, const Function_v2b<F>& fun) + { + trace::entering("binarization::impl::binarization_"); + mln_concrete_ch_value(I, bool) output; + + level::transform(input, fun, output); + + trace::exiting("binarization::impl::binarization_"); + return output; + } + + } // end of namespace mln::binarization::impl + + + template <typename I, typename F> + inline + mln_concrete_ch_value(I, bool) + binarization(const Image<I>& input, const Function_v2b<F>& fun) + { + trace::entering("binarization::binarization"); + mln_precondition(exact(input).has_data()); + mlc_is(mln_trait_value_nature(mln_value(I)), + trait::value::nature::scalar)::check(); + + mln_concrete_ch_value(I, bool) output(exact(input).domain()); + output = impl::binarization_(exact(input), fun); + + trace::exiting("binarization::binarization"); + return output; + } + +# endif // ! MLN_INCLUDE_ONLY + + } // end of namespace mln::binarization + +} // end of namespace mln + + +#endif // ! MLN_BINARIZATION_BINARIZATION_HH Index: abraham/mln/value/builtin/symbolics.hh --- abraham/mln/value/builtin/symbolics.hh (revision 0) +++ abraham/mln/value/builtin/symbolics.hh (revision 0) @@ -0,0 +1,76 @@ +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// 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 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +#ifndef MLN_VALUE_BUILTIN_SYMBOLICS_HH +# define MLN_VALUE_BUILTIN_SYMBOLICS_HH + +/*! \file mln/value/builtin/symbolics.hh + * + * \brief Some definitions about built-in symbolic types. + */ + +# include <mln/value/concept/built_in.hh> +# include <mln/value/concept/symbolic.hh> +# include <mln/trait/value_.hh> + + +namespace mln +{ + + + template <> + struct category< bool > + { + typedef value::Built_In< value::Symbolic<void> > ret; + }; + + + namespace trait + { + + template <> + struct value_< bool> + { + typedef value::nature::symbolic nature; + typedef value::kind::binary kind; + + enum { + nbits = 1, + card = 2 + }; + typedef value::quant::low quant; + + static bool min() { return false; } + static bool max() { return true;} + }; + + } // end of namespace mln::trait + +} // end of namespace mln + + +#endif // ! MLN_VALUE_BUILTIN_SYMBOLICS_HH Index: nature/erosion.cc --- nature/erosion.cc (revision 0) +++ nature/erosion.cc (revision 0) @@ -0,0 +1,59 @@ +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// 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 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +#include <mln/core/image/image2d.hh> +#include <mln/win/rectangle2d.hh> + +#include <mln/io/pgm/load.hh> +#include <mln/io/pgm/save.hh> + +#include <mln/value/int_u8.hh> +#include <mln/morpho/gradient.hh> + + +int main(int argc, const char * argv[]) +{ + using namespace mln; + using value::int_u8; + + if (argc < 2) { + std::cerr << "usage: " << argv[0] << " in.pgm [other_files.pgm]" << std::endl; + return 1; + } + + for (unsigned i = 1; i < argc; ++i) + { + image2d<int_u8> ima; + io::pgm::load(ima, argv[i]); + + win::hline2d f(31); + border::thickness = 16; + + io::pgm::save( morpho::erosion(ima, f), + "out.pgm" ); + } +} Index: nature/gradient.cc --- nature/gradient.cc (revision 0) +++ nature/gradient.cc (revision 0) @@ -0,0 +1,59 @@ +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// 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 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +#include <mln/core/image/image2d.hh> +#include <mln/win/rectangle2d.hh> + +#include <mln/io/pgm/load.hh> +#include <mln/io/pgm/save.hh> + +#include <mln/value/int_u8.hh> +#include <mln/morpho/gradient.hh> + + +int main(int argc, const char * argv[]) +{ + using namespace mln; + using value::int_u8; + + if (argc < 2) { + std::cerr << "usage: " << argv[0] << " in.pgm [other_files.pgm]" << std::endl; + return 1; + } + + for (unsigned i = 1; i < argc; ++i) + { + image2d<int_u8> ima; + io::pgm::load(ima, argv[i]); + + win::rectangle2d rect(5, 5); + border::thickness = 5; + + io::pgm::save( morpho::gradient(ima, rect), + "out.pgm" ); + } +} Index: nature/histo_hsi.cc --- nature/histo_hsi.cc (revision 0) +++ nature/histo_hsi.cc (revision 0) @@ -0,0 +1,166 @@ +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// 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 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +#include <iterator> +#include <string> + +#include <mln/core/image/image2d.hh> +#include <mln/core/image/cast_image.hh> +#include <mln/core/image/thru.hh> +#include <mln/core/alias/window2d.hh> +#include <mln/core/alias/neighb2d.hh> +#include <mln/core/site_set/p_set.hh> + +#include <mln/value/rgb8.hh> +#include <mln/value/hsi.hh> + +#include <mln/fun/v2v/rgb_to_hsi.hh> +#include <mln/fun/meta/hue.hh> +#include <mln/fun/meta/sat.hh> +#include <mln/fun/meta/inty.hh> + +#include <mln/level/compare.hh> + +#include <mln/io/ppm/load.hh> +#include <mln/io/pbm/save.hh> +#include <mln/io/pgm/save.hh> + +#include <mln/accu/histo.hh> +#include <mln/histo/compute.hh> +#include <mln/level/transform.hh> +#include <mln/level/fill.hh> + +using namespace mln; +using namespace value; + +typedef int_u16 u_t; + + +template <typename I> +void save_histo(Image<I> &i, std::string &name, unsigned width, unsigned height, unsigned npoints) +{ + I& ima = exact(i); + + histo::data<u_t> h = histo::compute(ima); + + double norm = (double) npoints / (double) height; + + image2d<bool> output(height + 1, width + 1, 0); + level::fill(output, true); + + mln_viter(mln::value::set<u_t>) v(h.vset()); + for_all(v) + if (h(v) > 0) + for (u_t i = 0; i < h(v)/norm; ++i) + { + // std::cout << height - i << ", " << (u_t)v << std::endl; + output(point2d(height - i, (u_t)v)) = false; + } + + io::pbm::save(output, name); +} + +int main (int argc, const char* argv []) +{ + if (argc < 2) { + std::cerr << "usage: " << argv[0] << " in.ppm [other_files.ppm]" << std::endl; + return 1; + } + + for (unsigned i = 1; i < argc; ++i) + { + + image2d<rgb8> input; + io::ppm::load(input, argv[i]); + + unsigned npoints = input.ncols() * input.nrows(); + + image2d<hsi_f> hsi = level::transform(input, fun::v2v::f_rgb_to_hsi_f); + thru<mln::meta::hue<hsi_f>, image2d<hsi_f> > h(hsi); + cast_image_<u_t, thru<mln::meta::hue<hsi_f>, image2d<hsi_f> > > hue(h); + + std::string n(argv[i]); + n.erase(n.length() - 4); + io::pgm::save(hue, n.append("_hue.pgm")); + + image2d<hsi_f>::piter p(hsi.domain()); + float m = 0; + for_all(p) + { + if (h(p) > m) + m = h(p); + } + std::cout << std::endl << m << std::endl; + + + + std::string name(argv[i]); + name.erase(name.length() - 4); + save_histo(hue, name.append("_hue.pbm"), 256, 360, npoints); + + thru<mln::meta::sat<hsi_f>, image2d<hsi_f> > s(hsi); + cast_image_<u_t, thru<mln::meta::sat<hsi_f>, image2d<hsi_f> > > sat(s); + + n = argv[i]; + n.erase(n.length() - 4); + io::pgm::save(sat, n.append("_sat.pgm")); + + m = 0; + for_all(p) + { + if (s(p) > m) + m = s(p); + } + std::cout << std::endl << m << std::endl; + + + name = argv[i]; + name.erase(name.length() - 4); + save_histo(sat, name.append("_sat.pbm"), 100, 2560, npoints); + + thru<mln::meta::inty<hsi_f>, image2d<hsi_f> > l(hsi); + cast_image_<u_t, thru<mln::meta::inty<hsi_f>, image2d<hsi_f> > > inty(l); + + n = argv[i]; + n.erase(n.length() - 4); + io::pgm::save(inty, n.append("_inty.pgm")); + + + m = 0; + for_all(p) + { + if (l(p) > m) + m = l(p); + } + std::cout << std::endl << m << std::endl; + + + name = argv[i]; + name.erase(name.length() - 4); + save_histo(inty, name.append("_inty.pbm"), 256, 256, npoints); + } +} Index: nature/hom.cc --- nature/hom.cc (revision 0) +++ nature/hom.cc (revision 0) @@ -0,0 +1,72 @@ +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// 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 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + + +#include <mln/core/image/image2d.hh> + +#include <mln/win/rectangle2d.hh> + +#include <mln/io/pgm/load.hh> +#include <mln/io/pbm/save.hh> + +#include <mln/value/int_u8.hh> + + + +#include <mln/level/transform.hh> +#include <mln/binarization/threshold.hh> +#include <mln/estim/mean.hh> +#include <mln/morpho/hit_or_miss.hh> + + + +int main(int argc, const char * argv[]) +{ + using namespace mln; + using value::int_u16; + + if (argc < 2) { + std::cerr << "usage: " << argv[0] << " in.pgm [other_files.pgm]" << std::endl; + return 1; + } + + for (unsigned i = 1; i < argc; ++i) + { + image2d<int_u16> ima; + io::pgm::load(ima, argv[i]); + + // Compute the mean + int_u16 mean = estim::mean(ima); + + win::rectangle2d rectout(3, 3); + win::rectangle2d rectin(5, 5); + + + io::pbm::save( morpho::hit_or_miss(binarization::threshold(ima, mean), rectout, rectin), + "out.pbm" ); + } +} Index: nature/opening.cc --- nature/opening.cc (revision 0) +++ nature/opening.cc (revision 0) @@ -0,0 +1,59 @@ +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// 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 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +#include <mln/core/image/image2d.hh> +#include <mln/win/rectangle2d.hh> + +#include <mln/io/pgm/load.hh> +#include <mln/io/pgm/save.hh> + +#include <mln/value/int_u8.hh> +#include <mln/morpho/opening.hh> + + +int main(int argc, const char * argv[]) +{ + using namespace mln; + using value::int_u8; + + if (argc < 2) { + std::cerr << "usage: " << argv[0] << " in.pgm [other_files.pgm]" << std::endl; + return 1; + } + + for (unsigned i = 1; i < argc; ++i) + { + image2d<int_u8> ima; + io::pgm::load(ima, argv[i]); + + win::rectangle2d rect(1, 51); + border::thickness = 100; + + io::pgm::save( morpho::opening(ima, rect), + "out.pgm" ); + } +} Index: nature/Makefile --- nature/Makefile (revision 0) +++ nature/Makefile (revision 0) @@ -0,0 +1,16 @@ +SRC=$(wildcard *.cc) +OBJ=$(SRC:.cc=.o) +EXEC=$(SRC:.cc=) +CC=g++ +CXXFLAGS=-Wall -W -I ../abraham -I ../.. -g + +all: $(EXEC) + +clean: + rm -rf *.o + rm -rf *~ + +distclean: clean + rm -rf $(EXEC) + +.PHONY: clean distclean