Index: olena/ChangeLog
from Niels Van Vliet <niels(a)lrde.epita.fr>
* oln/morpho/attribute_closing_opening_map.hh: Add file.
Attribute closing and opening using std::map.
* oln/morpho/attribute_closing_opening_map.hxx: Add file.
* oln/utils/special_points.hh: Add file. Point used as a state.
* tests/morpho/attributes: Add file. Add tests on attribute
closing and opening.
Index: olena/oln/morpho/attribute_closing_opening_map.hxx
--- olena/oln/morpho/attribute_closing_opening_map.hxx Tue, 10 Feb 2004
19:47:05 +0100 van-vl_n ()
+++ olena/oln/morpho/attribute_closing_opening_map.hxx Tue, 10 Feb 2004
19:18:13 +0100 van-vl_n (oln/j/48_attribute_ 644)
@@ -0,0 +1,194 @@
+// Copyright (C) 2004 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, 59 Temple Place - Suite 330, 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.
+
+
+namespace oln
+{
+ namespace morpho
+ {
+ template <class I, class D, class Env>
+ template <class N>
+ f_tarjan_map<I, D, Env>::f_tarjan_map(bool is_closing,
+ const typename f_tarjan_map<I, D, Env>::input_type& input,
+ const abstract::neighborhood<N>& ng,
+ const typename f_tarjan_map<I, D, Env>::lambda_type& lambda,
+ const Env & env) :
+ is_closing(is_closing),
+ input(input),
+ lambda(lambda),
+ parent(input.size()),
+ is_proc(input.size()),
+ output(input.size()),
+ env(env)
+ {
+ // init S and parent
+ typedef typename std::vector<point_type> vector_type;
+ vector_type S(input.npoints());
+ if (is_closing)
+ utils::distrib_sort(input, S);
+ else
+ utils::distrib_sort_inv(input, S);
+
+ level::fill(parent, inactive());
+ level::fill(is_proc, false);
+
+ // array S contains sorted pixel list
+ make_set(S[0]);
+ is_proc[S[0]] = true;
+
+ for (int ip = 1; ip < int(S.size()); ++ip)
+ {
+ point_type p = S[ip];
+
+ // p_ is the pixel just processed before p
+ point_type p_ = S[ip - 1];
+ if (input[p] != input[p_])
+ {
+ // for all the previous layer
+ for (int iq = ip - 1; iq >= 0; --iq)
+ {
+ point_type q = S[iq];
+ if (input[q] != input[p_])
+ break;
+ // if the attribute is 'reached', we do not need
+ // it anymore
+ if (parent[q] == active() && !(auxdata[q] < lambda))
+ {
+ parent[q] = inactive();
+ auxdata.erase(q);
+ }
+ }
+ }
+ make_set(p);
+
+ oln_neighb_type(N) n(ng, p);
+ for_all(n)
+ if (input.hold(n) && is_proc[n])
+ do_union(n, p);
+
+ is_proc[p] = true;
+ }
+
+ // resolving phase in reverse sort order
+
+ for (int ip = int(S.size()) - 1; ip >= 0; --ip)
+ {
+ point_type p = S[ip];
+ if (parent[p] == active() || parent[p] == inactive())
+ output[p] = input[p];
+ else
+ output[p] = output[parent[p]];
+ }
+ }
+
+ template <class I, class D, class Env>
+ const typename f_tarjan_map<I, D, Env>::point_type
+ f_tarjan_map<I, D, Env>::inactive()
+ {
+ static const point_type it =
utils::internal::mk_point_looking_like<point_type>(-2);
+ return it;
+ }
+
+ template <class I, class D, class Env>
+ const typename f_tarjan_map<I, D, Env>::point_type
+ f_tarjan_map<I, D, Env>::active()
+ {
+ static const point_type it =
utils::internal::mk_point_looking_like<point_type>(-1);
+ return it;
+ }
+
+ template <class I, class D, class Env>
+ void
+ f_tarjan_map<I, D, Env>::make_set(const typename f_tarjan_map<I, D,
Env>::point_type& x)
+ {
+ precondition(parent[x] == inactive());
+ parent[x] = active();
+ auxdata[x] = D(input, x, env);
+ }
+
+ template <class I, class D, class Env>
+ void
+ f_tarjan_map<I, D, Env>::link(const typename f_tarjan_map<I, D,
Env>::point_type& x,
+ const typename f_tarjan_map<I, D, Env>::point_type& y)
+ {
+ if (parent[x] == active() && parent[y] == active())
+ {
+ auxdata[y] += auxdata[x];
+ auxdata.erase(x);
+ }
+ else
+ if (parent[x] == active())
+ auxdata.erase(x);
+ else
+ {
+ parent[y] = inactive();
+ auxdata.erase(y);
+ }
+ parent[x] = y;
+ }
+
+ template <class I, class D, class Env>
+ typename f_tarjan_map<I, D, Env>::point_type
+ f_tarjan_map<I, D, Env>::find_root(const typename f_tarjan_map<I,
D, Env>::point_type& x)
+ {
+ if (parent[x] != active() && parent[x] != inactive())
+ {
+ parent[x] = find_root(parent[x]);
+ return parent[x];
+ }
+ return x;
+ }
+
+ template <class I, class D, class Env>
+ bool
+ f_tarjan_map<I, D, Env>::equiv(const typename f_tarjan_map<I, D,
Env>::point_type& x,
+ const typename f_tarjan_map<I, D, Env>::point_type& y) const
+ {
+ return input[x] == input[y] || parent[x] == active();
+ }
+
+ template <class I, class D, class Env>
+ void
+ f_tarjan_map<I, D, Env>::do_union(const typename f_tarjan_map<I, D,
Env>::point_type& n,
+ const typename f_tarjan_map<I, D, Env>::point_type& p)
+ {
+ point_type r = find_root(n);
+ if (r != p)
+ {
+ if (equiv(r, p))
+ link(r, p);
+ else
+ if (parent[p] == active())
+ {
+ parent[p] = inactive();
+ auxdata.erase(p);
+ }
+ }
+ }
+ } // end of namespace morpho
+} // end of namespace oln
+
Index: olena/oln/morpho/attribute_closing_opening_map.hh
--- olena/oln/morpho/attribute_closing_opening_map.hh Tue, 10 Feb 2004
19:47:05 +0100 van-vl_n ()
+++ olena/oln/morpho/attribute_closing_opening_map.hh Tue, 10 Feb 2004
19:18:13 +0100 van-vl_n (oln/j/49_attribute_ 644)
@@ -0,0 +1,151 @@
+// Copyright (C) 2004 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, 59 Temple Place - Suite 330, 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 OLENA_MORPHO_ATTRIBUTE_CLOSING_OPENING_MAP
+# define OLENA_MORPHO_ATTRIBUTE_CLOSING_OPENING_MAP
+# include <oln/morpho/attributes.hh>
+# include <oln/level/fill.hh>
+# include <oln/basics2d.hh>
+# include <ntg/int.hh>
+# include <oln/utils/histogram.hh>
+# include <oln/utils/special_points.hh>
+
+# include <iterator>
+# include <vector>
+# include <map>
+# include <algorithm>
+# include <utility>
+
+
+namespace oln
+{
+ namespace morpho
+ {
+
+ /*! Attribute closing using map. Smaller memory usage, but
+ * slower computation than the attribute_closing_opening
+ *
+ * See "Fast morphological attribute operations using Tarjan's
union-find
+ * algorithm" by Michael H. F. Wilkinson and Jos B. T. M. Roerdink
+ */
+ template <class I, class D, class Env = morpho::tarjan::NullEnv>
+ struct f_tarjan_map
+ {
+ public:
+ typedef abstract::image<I> input_type;
+ typedef oln_concrete_type(I) img_type;
+
+ typedef oln_point_type(input_type) point_type;
+ typedef oln_value_type(input_type) value_type;
+ typedef typename mute<input_type, point_type>::ret parent_type;
+ typedef typename mute<input_type, bool>::ret is_proc_type;
+ typedef typename D::lambda_type lambda_type;
+
+ // e.g.,
+ // when I is image2d<int_u8> and D is area_type, we've got:
+ // +--------------+------------------+
+ // | input_type | image2d<int_u8> |
+ // | point_type | point2d |
+ // | parent_type | image2d<point2d> |
+ // | is_proc_type | image2d<bool> |
+ // | lambda_type | int |
+ // +--------------+------------------+
+
+ template <class N>
+ f_tarjan_map(bool is_closing,
+ const input_type& input,
+ const abstract::neighborhood<N>& ng,
+ const lambda_type& lambda,
+ const Env & env = Env());
+
+ template<typename DestValue>
+ typename mute<I, DestValue>::ret
+ res()
+ {
+ return output;
+ }
+ protected:
+
+ static const point_type
+ inactive();
+
+ static const point_type
+ active();
+
+ void
+ make_set(const point_type& x);
+
+ void
+ link(const point_type& x, const point_type& y);
+
+ point_type
+ find_root(const point_type& x);
+
+ bool
+ equiv(const point_type& x, const point_type& y) const;
+
+ void
+ do_union(const point_type& n, const point_type& p);
+
+ const bool is_closing;
+ const input_type& input;
+ lambda_type lambda;
+ parent_type parent;
+ is_proc_type is_proc;
+ img_type output;
+ std::map<point_type, D, oln::internal::default_less<point_type> >
auxdata;
+ Env env;
+ };
+
+
+ /*! Attribute closing using map. Smaller memory usage, but
+ * slower computation than the attribute_closing_opening
+ *
+ * See "Fast morphological attribute operations using Tarjan's
union-find
+ * algorithm" by Michael H. F. Wilkinson and Jos B. T. M. Roerdink
+ */
+ template <typename DestValue, class I, class D, class Env, class N>
+ typename mute<I, DestValue>::ret
+ tarjan_map(bool is_closing,
+ const abstract::image<I>& input,
+ const abstract::neighborhood<N>& ng,
+ const typename D::lambda_type& lambda,
+ const Env & env = Env())
+ {
+ oln::morpho::f_tarjan_map<I, D, Env > t(is_closing,
+ input,
+ ng,
+ lambda,
+ env);
+ return t. template res<DestValue>();
+ }
+ } // end of namespace morpho
+} // end of namespace oln
+
+#include "attribute_closing_opening_map.hxx"
+
+#endif
Index: olena/oln/utils/special_points.hh
--- olena/oln/utils/special_points.hh Tue, 10 Feb 2004 19:47:05 +0100
van-vl_n ()
+++ olena/oln/utils/special_points.hh Tue, 10 Feb 2004 19:18:14 +0100
van-vl_n (oln/j/50_special_po 644)
@@ -0,0 +1,58 @@
+// Copyright (C) 2004 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, 59 Temple Place - Suite 330, 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 OLENA_UTILS_SPECIAL_POINTS_HH
+# define OLENA_UTILS_SPECIAL_POINTS_HH
+
+# include <oln/core/abstract/point.hh>
+
+namespace oln {
+
+ namespace utils {
+
+ namespace internal {
+ /*! Creates a point that is used as a state.
+ *
+ * This function should be called with a value unreachable
+ * for example a negative one.
+ */
+ template <class P>
+ P
+ mk_point_looking_like(coord value)
+ {
+ P p;
+ p.nth(0) = value;
+ return p;
+ }
+
+ } // end of namespace internal
+
+ } // end of namespace utils
+
+} // end of namespace oln
+
+#endif // ! OLENA_UTILS_SPECIAL_POINTS_HH
Index: olena/tests/morpho/tests/attribute
--- olena/tests/morpho/tests/attribute Tue, 10 Feb 2004 19:47:05 +0100
van-vl_n ()
+++ olena/tests/morpho/tests/attribute Tue, 10 Feb 2004 19:18:00 +0100
van-vl_n (oln/j/51_attribute 644)
@@ -0,0 +1,109 @@
+// -*- c++ -*-
+
+#include <oln/basics2d.hh>
+#include <oln/morpho/attribute_closing_opening.hh>
+#include <oln/morpho/attribute_closing_opening_map.hh>
+#include <oln/level/compare.hh>
+#include <ntg/all.hh>
+#include <oln/morpho/extrema_killer.hh>
+
+#include "check.hh"
+#include "data.hh"
+
+using namespace oln;
+using namespace ntg;
+
+#define OK_OR_FAIL \
+ std::cout << "OK" << std::endl; \
+ else \
+ { \
+ std::cout << "FAIL" << std::endl; \
+ fail = true; \
+ }
+
+//FIXME some algo are already checked.
+bool
+check_algo()
+{
+ bool fail(false);
+
+ typedef image2d<int_u8> img_type;
+ typedef oln::morpho::tarjan::area_type<unsigned> area_type;
+ const area_type::lambda_type area = 100;
+ const neighborhood2d nb = neighb_c8();
+ const oln::morpho::tarjan::NullEnv env;
+
+ img_type lena = load(rdata("lena.pgm"));
+ img_type lena_sure_closing = oln::morpho::sure_minima_killer(lena,
area, nb);
+ img_type lena_sure_opening = oln::morpho::sure_maxima_killer(lena,
area, nb);
+
+ img_type lena_tst_opening;
+ img_type lena_tst_closing;
+
+ std::cerr << "testing tarjan_map..." << std::endl;
+ lena_tst_closing =
morpho::tarjan_map<ntg::int_u8,img_type,area_type>(true, lena, nb,
area, env);
+ lena_tst_opening=
morpho::tarjan_map<ntg::int_u8,img_type,area_type>(false, lena, nb,
area, env);
+
+
+ fail = fail ||
+ !level::is_equal(lena_sure_closing, lena_tst_closing)||
+ !level::is_equal(lena_sure_opening, lena_tst_opening);
+
+ std::cerr << "fail:" << fail << std::endl;
+
+ std::cerr << "testing fast_minima_killer..." << std::endl;
+ lena_tst_closing = oln::morpho::fast_minima_killer(lena, area, nb);
+
+ fail = fail ||
+ !level::is_equal(lena_sure_closing, lena_tst_closing);
+ std::cerr << "fail:" << fail << std::endl;
+
+ std::cerr << "testing area_closin and area_opeing..." << std::endl;
+ lena_tst_closing = morpho::tarjan::area_closing(lena, nb, area);
+ lena_tst_opening = morpho::tarjan::area_opening(lena, nb, area);
+ fail = fail ||
+ !level::is_equal(lena_sure_closing, lena_tst_closing)||
+ !level::is_equal(lena_sure_opening, lena_tst_opening);
+ std::cerr << "fail:" << fail << std::endl;
+ //FIXME at least 1 other algo should be checked
+
+ return fail;
+}
+
+
+bool
+check_attribute()
+{
+ //FIXME attributes should be checked
+ return false;
+}
+
+
+bool
+check_env()
+{
+ //FIXME env should be checked
+ return false;
+}
+bool
+check()
+{
+ bool fail = false;
+
+ std::cerr << "FIXME: check_attribute and check_env are empty."
+ << std::endl;
+
+ std::cout << "check algo... " << std::flush;
+ if (check_algo() == false)
+ OK_OR_FAIL;
+
+ std::cout << "check attribute... " << std::flush;
+ if (check_attribute() == false)
+ OK_OR_FAIL;
+
+ std::cout << "check env... " << std::flush;
+ if (check_env() == false)
+ OK_OR_FAIL;
+
+ return fail;
+}
Index: olena/ChangeLog
from Niels Van Vliet <niels(a)lrde.epita.fr>
* oln/core/abstract/image.hh: Remove macro oln_neighb_type.
* oln/core/abstract/neighborhood.hh: Add macro oln_neighb_type.
* oln/core/utils/histogram.hh: Add a FIXME.
+2004-02-10 Niels Van Vliet <niels(a)lrde.epita.fr>
+
* oln/morpho/attribute_closing_opening_map.hh: Add file.
Attribute closing and opening using std::map.
* oln/morpho/attribute_closing_opening_map.hxx: Add file.
Index: olena/oln/core/abstract/neighborhood.hh
--- olena/oln/core/abstract/neighborhood.hh Thu, 07 Aug 2003 02:08:21
+0200 david (oln/c/38_neighborho 1.18 640)
+++ olena/oln/core/abstract/neighborhood.hh Wed, 11 Feb 2004 09:11:56
+0100 van-vl_n (oln/c/38_neighborho 1.18 640)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2002, 2003 EPITA Research and Development
Laboratory
+// Copyright (C) 2001, 2002, 2003, 2004 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
@@ -175,6 +175,9 @@
return win;
}
+# define oln_neighb_type(Neighbable) \
+typename Neighbable::neighb_type
+
} // end of oln
Index: olena/oln/utils/histogram.hh
--- olena/oln/utils/histogram.hh Tue, 10 Feb 2004 17:32:17 +0100 palma_g
(oln/10_histogram. 1.6.1.14.1.5 640)
+++ olena/oln/utils/histogram.hh Wed, 11 Feb 2004 09:15:27 +0100
van-vl_n (oln/10_histogram. 1.6.1.14.1.5 640)
@@ -84,6 +84,9 @@
namespace abstract
{
+ // FIXME: An image is inside the histogram. This is incorrect
+ // because it is not exactly an image (we do not need any
+ // border).
template<class T,
typename CPT,
class Exact = mlc::final>
Index: olena/oln/core/abstract/image.hh
--- olena/oln/core/abstract/image.hh Mon, 01 Sep 2003 20:12:38 +0200
burrus_n (oln/t/25_image.hh 1.19 640)
+++ olena/oln/core/abstract/image.hh Wed, 11 Feb 2004 09:11:57 +0100
van-vl_n (oln/t/25_image.hh 1.19 640)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2003 EPITA Research and Development Laboratory
+// Copyright (C) 2001, 2003, 2004 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
@@ -209,9 +209,6 @@
# define oln_dpoint_type(DPointable) \
mlc_exact_type(DPointable)::dpoint_type
-# define oln_neighb_type(Neighbable) \
-typename Neighbable::neighb_type
-
} // end of namespace oln
#endif // ! OLENA_CORE_ABSTRACT_IMAGE_HH
Oleneux, Oleneux
Il faudrait que chacun mette à jour sa section de la page assignement
du twiki, de manière à la rendre beaucoup plus précise qu'elle ne l'est
actuellement. L'idéal serait qu'y figure notre travail hebdomadaire.
http://www.lrde.epita.fr/cgi-bin/twiki/view/Projects/OlenaAssignments
--
Simon Odou
simon(a)lrde.epita.fr
Index: ChangeLog
from Giovanni Palma <giovanni(a)lrde.epita.fr>
* NEWS: Describe behavior hierarchy.
Index: olena/ChangeLog
from Giovanni Palma <giovanni(a)lrde.epita.fr>
* oln/core/abstract/behavior.hh: Add behavior hierarchy (abstract
part).
* oln/core/behavior.hh: Add behavior hierarchy content.
* oln/morpho/attributes.hh: Correct 'ifndef' macros.
* tests/convol/tests/uniform_gauss: Improve tests.
* oln/convol/fast_gaussian.hh: Make the gaussian take care of the
behavior hierarchy.
* oln/convol/fast_gaussian.hxx: Likewise.
Index: NEWS
--- NEWS Mon, 09 Feb 2004 18:57:03 +0100 palma_g (oln/0_NEWS 1.17 640)
+++ NEWS Tue, 10 Feb 2004 15:25:07 +0100 palma_g (oln/0_NEWS 1.17 640)
@@ -1,11 +1,18 @@
Olena 0.10 Not yet
+ * Border behavior can be controlled with the behavior hierarchy.
+ If an algorithm support it, you can choose the way the image
+ border will be seen. Three behaviors are available: mirror,
+ replicate or user defined value.
+
* Attribute opening/closing enhancement
- - Make the algothim more generic.
- - Add a lot of attributes.
+ - Make the algorithm more generic.
+ - Add a lot of attributes (area, disk, square, dist,
+ rectangle, volume, height, maxvalue, minvalue).
* Change the color conversion system
- - CIE RGB is the main color system.
+ - CIE RGB is the main color system e.g. it can be converted
+ directly into any other color system.
- Conversion between 2 color systems should pass by the RGB one.
Olena 0.9 August 8, 2003
Index: olena/oln/convol/fast_gaussian.hh
--- olena/oln/convol/fast_gaussian.hh Thu, 07 Aug 2003 02:08:21 +0200 david (oln/26_fast_gauss 1.6.1.6.1.3 640)
+++ olena/oln/convol/fast_gaussian.hh Tue, 10 Feb 2004 14:56:04 +0100 palma_g (oln/26_fast_gauss 1.6.1.6.1.3 640)
@@ -31,7 +31,7 @@
# include <oln/basics.hh>
# include <oln/convert/basics.hh>
# include <ntg/float.hh>
-
+# include <oln/core/behavior.hh>
//
// Gaussian filter implementation from
// "Recursively implementing the gaussian and its derivatives"
@@ -44,39 +44,66 @@
// FIXME: add tests!
- template <class C, class B, class I>
+ template <class C, class B, class I, class BE>
typename mute<I, typename convoutput<C, B, oln_value_type(I)>::ret>::ret
gaussian(const convert::abstract::conversion<C, B>& input_conv,
- const abstract::image<I>& in, ntg::float_s sigma);
+ const abstract::image<I>& in, ntg::float_s sigma,
+ const abstract::behavior<BE> &behavior);
- template <class C, class B, class I>
+ template <class C, class B, class I, class BE>
typename mute<I, typename convoutput<C, B, oln_value_type(I)>::ret>::ret
gaussian_derivative(const convert::abstract::conversion<C, B>& input_conv,
- const abstract::image<I>& in, ntg::float_s sigma);
- template <class C, class B, class I>
+ const abstract::image<I>& in, ntg::float_s sigma,
+ const abstract::behavior<BE> &behavior);
+ template <class C, class B, class I, class BE>
typename mute<I, typename convoutput<C, B, oln_value_type(I)>::ret>::ret
gaussian_second_derivative(const convert::abstract::conversion<C, B>& input_conv,
const abstract::image<I>& in,
- ntg::float_s sigma);
+ ntg::float_s sigma,
+ const abstract::behavior<BE> &behavior);
/* Same functions, with a default conversion. */
+ template <class I, class BE> inline
+ oln_concrete_type(I)
+ gaussian(const abstract::image<I>& in, ntg::float_s sigma,
+ const abstract::behavior<BE> &behavior)
+ { return gaussian(convert::force<oln_value_type(I)>(), in, sigma,
+ behavior); }
+
+ template <class I, class BE> inline
+ oln_concrete_type(I)
+ gaussian_derivative(const abstract::image<I>& in, ntg::float_s sigma,
+ const abstract::behavior<BE> &behavior)
+ { return gaussian_derivative(convert::force<oln_value_type(I)>(), in, sigma,
+ behavior); }
+
+ template <class I, class BE> inline
+ oln_concrete_type(I)
+ gaussian_second_derivative(const abstract::image<I>& in,
+ ntg::float_s sigma,
+ const abstract::behavior<BE> &behavior = mirror_behavior<>())
+ { return gaussian_second_derivative(convert::force<oln_value_type(I)>(),
+ in, sigma, behavior); }
+
+ /* Same functions, with a default behavior (mirror_behavior). */
template <class I> inline
oln_concrete_type(I)
gaussian(const abstract::image<I>& in, ntg::float_s sigma)
- { return gaussian(convert::force<oln_value_type(I)>(), in, sigma); }
+ { return gaussian(convert::force<oln_value_type(I)>(), in, sigma,
+ mirror_bhv()); }
template <class I> inline
oln_concrete_type(I)
gaussian_derivative(const abstract::image<I>& in, ntg::float_s sigma)
- { return gaussian_derivative(convert::force<oln_value_type(I)>(), in, sigma); }
+ { return gaussian_derivative(convert::force<oln_value_type(I)>(), in, sigma,
+ mirror_bhv()); }
template <class I> inline
oln_concrete_type(I)
- gaussian_second_derivative(const abstract::image<I>& in,
- ntg::float_s sigma)
- { return gaussian_second_derivative(convert::force<oln_value_type(I)>(),
- in, sigma); }
+ gaussian_second_derivative(const abstract::image<I>& in, ntg::float_s sigma)
+ { return gaussian_second_derivative(convert::force<oln_value_type(I)>(), in, sigma,
+ mirror_bhv()); }
}
}
}
Index: olena/oln/convol/fast_gaussian.hxx
--- olena/oln/convol/fast_gaussian.hxx Wed, 28 Jan 2004 16:28:44 +0100 palma_g (oln/25_fast_gauss 1.7.1.8.1.5 640)
+++ olena/oln/convol/fast_gaussian.hxx Tue, 10 Feb 2004 13:09:29 +0100 palma_g (oln/25_fast_gauss 1.7.1.8.1.5 640)
@@ -230,12 +230,13 @@
}
};
- template <class C, class B, class I, class F>
+ template <class C, class B, class I, class F, class BE>
typename mute<I, typename convoutput<C,B,oln_value_type(I)>::ret>::ret
gaussian_common_(const convert::abstract::conversion<C,B>& c,
const abstract::image<I>& in,
const F& coef,
- ntg::float_s sigma)
+ ntg::float_s sigma,
+ const abstract::behavior<BE> &behavior)
{
typename mute<I, ntg::float_s>::ret work_img(in.size());
@@ -247,7 +248,7 @@
be linear, so when sigma is big enougth, the signal may
be parasitized by the non signal values.
*/
- work_img.border_adapt_mirror(ntg::cast::round<coord>(5 * sigma));
+ behavior.adapt_border(work_img, ntg::cast::round<coord>(5 * sigma));
gaussian_<I::dim>::doit(work_img, coef);
@@ -265,10 +266,11 @@
} // internal
- template <class C, class B, class I>
+ template <class C, class B, class I, class BE>
typename mute<I, typename convoutput<C,B,oln_value_type(I)>::ret>::ret
gaussian(const convert::abstract::conversion<C,B>& c,
- const abstract::image<I>& in, ntg::float_s sigma)
+ const abstract::image<I>& in, ntg::float_s sigma,
+ const abstract::behavior<BE> &behavior)
{
internal::recursivefilter_coef_<float>
coef(1.68f, 3.735f,
@@ -278,13 +280,14 @@
sigma,
internal::recursivefilter_coef_<float>::DericheGaussian);
- return internal::gaussian_common_(c, in, coef, sigma);
+ return internal::gaussian_common_(c, in, coef, sigma, behavior);
}
- template <class C, class B, class I>
+ template <class C, class B, class I, class BE>
typename mute<I, typename convoutput<C,B,oln_value_type(I)>::ret>::ret
gaussian_derivative(const convert::abstract::conversion<C,B>& c,
- const abstract::image<I>& in, ntg::float_s sigma)
+ const abstract::image<I>& in, ntg::float_s sigma,
+ const abstract::behavior<BE> &behavior)
{
internal::recursivefilter_coef_<float>
coef(-0.6472f, -4.531f,
@@ -295,13 +298,14 @@
internal::recursivefilter_coef_<float>
::DericheGaussianFirstDerivative);
- return internal::gaussian_common_(c, in, coef, sigma);
+ return internal::gaussian_common_(c, in, coef, sigma, behavior);
}
- template <class C, class B, class I>
+ template <class C, class B, class I, class BE>
typename mute<I, typename convoutput<C,B,oln_value_type(I)>::ret>::ret
gaussian_second_derivative(const convert::abstract::conversion<C,B>& c,
- const abstract::image<I>& in, ntg::float_s sigma)
+ const abstract::image<I>& in, ntg::float_s sigma,
+ const abstract::behavior<BE> &behavior)
{
internal::recursivefilter_coef_<float>
coef(-1.331f, 3.661f,
@@ -312,7 +316,7 @@
internal::recursivefilter_coef_<float>
::DericheGaussianSecondDerivative);
- return internal::gaussian_common_(c, in, coef, sigma);
+ return internal::gaussian_common_(c, in, coef, sigma, behavior);
}
} // fast
Index: olena/tests/convol/tests/uniform_gauss
--- olena/tests/convol/tests/uniform_gauss Fri, 30 Jan 2004 10:25:13 +0100 palma_g (oln/j/41_uniform_ga 1.1 644)
+++ olena/tests/convol/tests/uniform_gauss Tue, 10 Feb 2004 15:17:49 +0100 palma_g (oln/j/41_uniform_ga 1.1 644)
@@ -23,9 +23,10 @@
for_all(it)
img[it] = 42;
image2d<int_u8> img2 = convol::fast::gaussian(img, 5);
+ image2d<int_u8> img3 = convol::fast::gaussian(img, 5, replicate_bhv());
for_all(it)
- if (img[it] != img2[it])
+ if ((img[it] != img2[it]) || (img[it] != img3[it]))
return true;
return false;
}
Index: olena/oln/morpho/attributes.hh
--- olena/oln/morpho/attributes.hh Mon, 09 Feb 2004 18:57:03 +0100 palma_g (oln/j/45_attributes 1.2 644)
+++ olena/oln/morpho/attributes.hh Tue, 10 Feb 2004 14:59:24 +0100 palma_g (oln/j/45_attributes 1.2 644)
@@ -25,18 +25,11 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef ATTRIBUTES_HH
-# define ATTRIBUTES_HH
+#ifndef OLN_MORPHO_ATTRIBUTES_HH
+# define OLN_MORPHO_ATTRIBUTES_HH
# include <mlc/type.hh>
# include <vector>
-// some usefull macros
-
-// those macros should be moved into mlc
-// # define mlc_exact_vt_type(T, Exact) typename mlc::exact_vt<T, Exact>::ret
-// # define oln_2_exact_vt_type(self, T, Exact) typename mlc::exact_vt<self<T, Exact>, Exact>::ret
-// # define dispatch(Fun) return exact().Fun##_impl
-
// attribute dedicated macros
# define attr_lambda_type(T) typename attr_traits<T>::lambda_type
# define attr_env_type(T) typename attr_traits<T>::env_type
@@ -859,5 +852,5 @@
// FIXME: to be written...
-#endif // ndef ATTRIBUTES_HH
+#endif // !OLN_MORPHO_ATTRIBUTES
Index: olena/oln/core/abstract/behavior.hh
--- olena/oln/core/abstract/behavior.hh Tue, 10 Feb 2004 15:33:34 +0100 palma_g ()
+++ olena/oln/core/abstract/behavior.hh Tue, 10 Feb 2004 14:54:58 +0100 palma_g (oln/j/46_behavior.h 644)
@@ -0,0 +1,57 @@
+// Copyright (C) 2004 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, 59 Temple Place - Suite 330, 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 OLENA_CORE_ABSTRACT_BEHAVIOR_HH
+# define OLENA_CORE_ABSTRACT_BEHAVIOR_HH
+# include <mlc/type.hh>
+# include <oln/core/abstract/image.hh>
+# include <oln/core/coord.hh>
+
+namespace oln {
+ namespace abstract {
+ // behavior hierarchy
+ //the aim of this one is to describe how an algorithm should work
+ //on borders
+ template <class Exact>
+ class behavior: public mlc_hierarchy::any<Exact>
+ {
+ public:
+ typedef behavior<Exact> self_type;
+ typedef mlc_exact_vt_type(self_type, Exact) exact_type;
+
+ template <class I>
+ void adapt_border(oln::abstract::image<I> &im, coord border_size) const
+ {
+ mlc_dispatch(adapt_border)(im, border_size);
+ };
+ protected:
+ behavior() {};
+ };
+ } // !abstract
+}
+
+#endif // !OLENA_CORE_ABSTRACT_BEHAVIOR_HH
Index: olena/oln/core/behavior.hh
--- olena/oln/core/behavior.hh Tue, 10 Feb 2004 15:33:34 +0100 palma_g ()
+++ olena/oln/core/behavior.hh Tue, 10 Feb 2004 15:12:48 +0100 palma_g (oln/j/47_behavior.h 644)
@@ -0,0 +1,108 @@
+// Copyright (C) 2004 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, 59 Temple Place - Suite 330, 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 OLENA_CORE_BEHAVIOR_HH
+# define OLENA_CORE_BEHAVIOR_HH
+# include <oln/core/abstract/behavior.hh>
+# include <mlc/type.hh>
+
+namespace oln {
+ // mirror the image content into the border
+ template <class Exact = mlc::final>
+ class mirror_behavior:
+ public abstract::behavior<mlc_exact_vt_type(mirror_behavior<Exact>, Exact)>
+ {
+ public:
+ typedef mirror_behavior<Exact> self_type;
+ typedef mlc_exact_vt_type(self_type, Exact) exact_type;
+
+ template <class I>
+ void adapt_border_impl(oln::abstract::image<I> &im, coord border_size) const
+ {
+ im.border_adapt_mirror(border_size);
+ };
+ };
+
+ // set the border to a specific value
+ template <class T, class Exact = mlc::final>
+ class value_behavior:
+ public abstract::behavior<mlc_2_exact_vt_type(value_behavior, T, Exact)>
+ {
+ public:
+ typedef value_behavior<T, Exact> self_type;
+ typedef mlc_exact_vt_type(self_type, Exact) exact_type;
+ typedef T value_type;
+
+ explicit value_behavior(value_type value): value_(value)
+ {
+ };
+
+ template <class I>
+ void adapt_border_impl(abstract::image<I> &im, coord border_size) const
+ {
+ im.border_adapt_assign(border_size, ntg::cast::force<oln_value_type(I)>(value_));
+ };
+
+ protected:
+ value_type value_;
+ };
+
+ // replicate the border
+ template <class Exact = mlc::final>
+ class replicate_behavior:
+ public abstract::behavior<mlc_exact_vt_type(replicate_behavior<Exact>, Exact)>
+ {
+ public:
+ typedef replicate_behavior<Exact> self_type;
+ typedef mlc_exact_vt_type(self_type, Exact) exact_type;
+
+ template <class I>
+ void adapt_border_impl(abstract::image<I> &im, coord border_size) const
+ {
+ im.border_adapt_copy(border_size);
+ };
+ };
+
+ // tools to call ctors with type inference
+ inline mirror_behavior<> mirror_bhv()
+ {
+ return mirror_behavior<>();
+ }
+
+ template <class T>
+ inline value_behavior<T> value_bhv(const T &value)
+ {
+ return value_behavior<T>(value);
+ }
+
+ inline replicate_behavior<> replicate_bhv()
+ {
+ return replicate_behavior<>();
+ }
+} // !oln
+
+#endif // !OLN_CORE_BEHAVIOR_HH
--
Giovanni Palma
EPITA - promo 2005 - membre d'EpX - LRDE
Mob. : +33 (0)6 60 97 31 74