* mln/transform/closest_point_geodesic.hh: rename as...
* mln/transform/distance_and_closest_point_geodesic.hh: ... this.
Now returns both dmap and closest point images.
Add a version returning a closest point image containing indexes.
* mln/transform/all.hh: update includes.
* mln/transform/internal/closest_point_functor.hh: add a new functor
which build a closest point image containing sites.
* tests/Makefile.am: run transform tests.
* tests/transform/Makefile.am: update test names
.
* tests/transform/bench_closest_point_geodesic.cc: fix missing
include.
* tests/transform/closest_point_geodesic.cc: rename as...
* tests/transform/distance_and_closest_point_geodesic.cc: ... this.
Update according modifications in
distance_and_closest_point_geodesic.hh.
---
milena/ChangeLog | 26 +++
milena/mln/transform/all.hh | 2 +-
milena/mln/transform/closest_point_geodesic.hh | 81 --------
.../distance_and_closest_point_geodesic.hh | 143 ++++++++++++++
.../transform/internal/closest_point_functor.hh | 196 ++++++++++++++++++--
milena/tests/Makefile.am | 1 +
milena/tests/transform/Makefile.am | 4 +-
.../transform/bench_closest_point_geodesic.cc | 1 +
milena/tests/transform/closest_point_geodesic.cc | 54 ------
.../distance_and_closest_point_geodesic.cc | 95 ++++++++++
10 files changed, 446 insertions(+), 157 deletions(-)
delete mode 100644 milena/mln/transform/closest_point_geodesic.hh
create mode 100644 milena/mln/transform/distance_and_closest_point_geodesic.hh
delete mode 100644 milena/tests/transform/closest_point_geodesic.cc
create mode 100644 milena/tests/transform/distance_and_closest_point_geodesic.cc
diff --git a/milena/ChangeLog b/milena/ChangeLog
index c8b7f2c..8216a5f 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,31 @@
2009-03-02 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+ Introduce distance_and_closest_point_geodesic.
+
+ * mln/transform/closest_point_geodesic.hh: rename as...
+ * mln/transform/distance_and_closest_point_geodesic.hh: ... this.
+ Now returns both dmap and closest point images.
+ Add a version returning a closest point image containing indexes.
+
+ * mln/transform/all.hh: update includes.
+
+ * mln/transform/internal/closest_point_functor.hh: add a new functor
+ which build a closest point image containing sites.
+
+ * tests/Makefile.am: run transform tests.
+
+ * tests/transform/Makefile.am: update test names
+ .
+ * tests/transform/bench_closest_point_geodesic.cc: fix missing
+ include.
+
+ * tests/transform/closest_point_geodesic.cc: rename as...
+ * tests/transform/distance_and_closest_point_geodesic.cc: ... this.
+ Update according modifications in
+ distance_and_closest_point_geodesic.hh.
+
+2009-03-02 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
Add util::couple.
* mln/util/couple.hh: New. behaves like a std::pair.
diff --git a/milena/mln/transform/all.hh b/milena/mln/transform/all.hh
index 256a4e8..4967197 100644
--- a/milena/mln/transform/all.hh
+++ b/milena/mln/transform/all.hh
@@ -42,7 +42,7 @@ namespace mln
} // end of namespace mln
-# include <mln/transform/closest_point_geodesic.hh>
+# include <mln/transform/distance_and_closest_point_geodesic.hh>
# include <mln/transform/distance_front.hh>
# include <mln/transform/distance_geodesic.hh>
# include <mln/transform/influence_zone_front.hh>
diff --git a/milena/mln/transform/closest_point_geodesic.hh b/milena/mln/transform/closest_point_geodesic.hh
deleted file mode 100644
index 0761d00..0000000
--- a/milena/mln/transform/closest_point_geodesic.hh
+++ /dev/null
@@ -1,81 +0,0 @@
-// 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. This exception does not however invalidate any other
-// reasons why the executable file might be covered by the GNU General
-// Public License.
-
-#ifndef MLN_TRANSFORM_CLOSEST_POINT_GEODESIC_HH
-# define MLN_TRANSFORM_CLOSEST_POINT_GEODESIC_HH
-
-/// \file mln/transform/closest_point_geodesic.hh
-///
-/// Geodesic closest point transform.
-///
-/// \todo Add a version to retrieve both distance and closest point
-/// maps.
-
-# include <mln/canvas/distance_geodesic.hh>
-# include <mln/transform/internal/closest_point_functor.hh>
-
-
-
-namespace mln
-{
-
- namespace transform
- {
-
- /// Discrete geodesic distance transform.
- template <typename I, typename N, typename D>
- mln_ch_value(I, mln_psite(I))
- closest_point_geodesic(const Image<I>& input, const Neighborhood<N>& nbh, D max);
-
-
-# ifndef MLN_INCLUDE_ONLY
-
- template <typename I, typename N, typename D>
- inline
- mln_ch_value(I, mln_psite(I))
- closest_point_geodesic(const Image<I>& input, const Neighborhood<N>& nbh, D max)
- {
- trace::entering("transform::closest_point_geodesic");
-
- mln_precondition(exact(input).is_valid());
- mln_precondition(exact(nbh).is_valid());
-
- internal::closest_point_functor<I> f;
- (void) mln::canvas::distance_geodesic(input, nbh, max, f);
-
- trace::exiting("transform::closest_point_geodesic");
- return f.cp_ima;
- }
-
-# endif // ! MLN_INCLUDE_ONLY
-
- } // end of namespace mln::transform
-
-} // end of namespace mln
-
-
-#endif // ! MLN_TRANSFORM_CLOSEST_POINT_GEODESIC_HH
diff --git a/milena/mln/transform/distance_and_closest_point_geodesic.hh b/milena/mln/transform/distance_and_closest_point_geodesic.hh
new file mode 100644
index 0000000..efc63ab
--- /dev/null
+++ b/milena/mln/transform/distance_and_closest_point_geodesic.hh
@@ -0,0 +1,143 @@
+// Copyright (C) 2008, 2009 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.
+
+#ifndef MLN_TRANSFORM_DISTANCE_AND_CLOSEST_POINT_GEODESIC_HH
+# define MLN_TRANSFORM_DISTANCE_AND_CLOSEST_POINT_GEODESIC_HH
+
+/// \file mln/transform/distance_and_closest_point_geodesic.hh
+///
+/// Distance and geodesic closest point transform.
+
+# include <mln/canvas/distance_geodesic.hh>
+# include <mln/transform/internal/closest_point_functor.hh>
+
+# include <mln/data/fill.hh>
+# include <mln/util/couple.hh>
+
+
+namespace mln
+{
+
+ namespace transform
+ {
+
+ /// Discrete geodesic distance transform
+ ///
+ /// \param[in] input Image from which the geodesic distance is computed.
+ /// \param[in] nbh Neighborhood
+ /// \param[in] max Max distance of propagation.
+ ///
+ /// \return a couple of images. The first one is the distance map and the
+ /// second one is the closest point image. The closest point image
+ /// contains sites.
+ ///
+ /// \post The returned images have the same domain as \p input.
+ template <typename I, typename N, typename D>
+ util::couple<mln_ch_value(I,D), mln_ch_value(I,mln_psite(I))>
+ distance_and_closest_point_geodesic(const Image<I>& input,
+ const Neighborhood<N>& nbh,
+ D max);
+
+
+ /// Discrete geodesic distance transform
+ ///
+ /// \param[in] pset an array of sites.
+ /// \param[in] closest_point_domain domain of the returned image.
+ /// \param[in] nbh neighborhood
+ /// \param[in] max max distance of propagation.
+ ///
+ /// \return A couple of images. The first one is the distance map and the
+ /// second one is the closest point image. The closest point image
+ /// contains site indexes.
+ ///
+ /// \post The returned image domains are defined on \p closest_point_domain.
+ template <typename P, typename N, typename D>
+ util::couple<mln_image_from_grid(mln_grid(P),D),
+ mln_image_from_grid(mln_grid(P),unsigned)>
+ distance_and_closest_point_geodesic(const p_array<P>& pset,
+ const box<P>& closest_point_domain,
+ const Neighborhood<N>& nbh,
+ D max);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename N, typename D>
+ inline
+ util::couple<mln_ch_value(I,D), mln_ch_value(I, mln_psite(I))>
+ distance_and_closest_point_geodesic(const Image<I>& input,
+ const Neighborhood<N>& nbh,
+ D max)
+ {
+ trace::entering("transform::distance_closest_point_geodesic");
+
+ mln_precondition(exact(input).is_valid());
+ mln_precondition(exact(nbh).is_valid());
+
+ internal::closest_point_functor_with_sites<I> f;
+ mln_ch_value(I,D) dmap = mln::canvas::distance_geodesic(input, nbh,
+ max, f);
+
+ trace::exiting("transform::distance_and_closest_point_geodesic");
+ return make::couple(dmap, f.cp_ima);
+ }
+
+ template <typename P, typename N, typename D>
+ inline
+ util::couple<mln_image_from_grid(mln_grid(P),D), mln_image_from_grid(mln_grid(P),unsigned)>
+ distance_and_closest_point_geodesic(const p_array<P>& pset,
+ const box<P>& closest_point_domain,
+ const Neighborhood<N>& nbh,
+ D max)
+ {
+ trace::entering("transform::distance_and_closest_point_geodesic");
+
+ mln_precondition(closest_point_domain.is_valid());
+ mln_precondition(exact(nbh).is_valid());
+ mln_precondition(geom::bbox(pset) <= closest_point_domain);
+
+ typedef mln_image_from_grid(mln_grid(P), bool) I;
+ internal::closest_point_functor_with_indexes<I> f(pset);
+
+ I ima(closest_point_domain);
+ data::fill(ima, false);
+ data::fill((ima | pset).rw(), true);
+
+ mln_ch_value(I,D) dmap = mln::canvas::distance_geodesic(ima, nbh, max, f);
+
+ trace::exiting("transform::distance_and_closest_point_geodesic");
+ return make::couple(dmap, f.cp_ima);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::transform
+
+} // end of namespace mln
+
+
+#endif // ! MLN_TRANSFORM_DISTANCE_AND_CLOSEST_POINT_GEODESIC_HH
diff --git a/milena/mln/transform/internal/closest_point_functor.hh b/milena/mln/transform/internal/closest_point_functor.hh
index 5cbac15..8df47b7 100644
--- a/milena/mln/transform/internal/closest_point_functor.hh
+++ b/milena/mln/transform/internal/closest_point_functor.hh
@@ -47,31 +47,55 @@ namespace mln
{
template <typename I>
- struct closest_point_functor
+ struct closest_point_functor_with_indexes
{
typedef mln_value(I) V;
- typedef mln_psite(I) P;
+ typedef mln_psite(I) P;
- closest_point_functor(const p_array<P>& pset);
+ closest_point_functor_with_indexes(const p_array<P>& pset);
mln_ch_value(I,unsigned) cp_ima;
const p_array<P>& pset_;
+ /// Generic version interface.
void init(const I&);
bool inqueue_p_wrt_input_p(const V& input_p);
void init_p(const P&);
bool inqueue_p_wrt_input_n(const V& input_n);
void process(const P&, const P&);
- void init_(const I& input)
- {
- init(input);
- }
+ /// Fast version interface.
+ void init_(const I& input);
+ bool inqueue_p_wrt_input_p_(const V& input_p);
+ void init_p_(unsigned);
+ bool inqueue_p_wrt_input_n_(const V& input_n);
+ void process_(unsigned p, unsigned n);
+ };
+
+
+ template <typename I>
+ struct closest_point_functor_with_sites
+ {
+ typedef mln_value(I) V;
+ typedef mln_psite(I) P;
+
+ closest_point_functor_with_sites();
+
+ mln_ch_value(I,P) cp_ima;
- bool inqueue_p_wrt_input_p_(const V& input_p) { return input_p == true; }
- void init_p_(unsigned) { }//cp_ima.element(p) = pset_(cp_ima.point_at_index(p)); }
- bool inqueue_p_wrt_input_n_(const V& input_n) { return input_n == false; }
- void process_(unsigned p, unsigned n) { cp_ima.element(n) = cp_ima.element(p); }
+ /// Generic version interface.
+ void init(const I&);
+ bool inqueue_p_wrt_input_p(const V& input_p);
+ void init_p(const P&);
+ bool inqueue_p_wrt_input_n(const V& input_n);
+ void process(const P&, const P&);
+
+ /// Fast version interface.
+ void init_(const I& input);
+ bool inqueue_p_wrt_input_p_(const V& input_p);
+ void init_p_(unsigned p);
+ bool inqueue_p_wrt_input_n_(const V& input_n);
+ void process_(unsigned p, unsigned n);
};
@@ -79,7 +103,8 @@ namespace mln
template <typename I>
inline
- closest_point_functor<I>::closest_point_functor(const p_array<mln_psite(I)>& pset)
+ closest_point_functor_with_indexes<I>::closest_point_functor_with_indexes(
+ const p_array<mln_psite(I)>& pset)
: pset_(pset)
{
}
@@ -87,20 +112,111 @@ namespace mln
template <typename I>
inline
void
- closest_point_functor<I>::init(const I& input)
+ closest_point_functor_with_indexes<I>::init(const I& input)
{
initialize(cp_ima, input);
data::fill(cp_ima, 0u);
mln_piter(p_array<mln_psite(I)>) p(pset_);
for_all(p)
- cp_ima(p) = p.index();
+ cp_ima(p) = cp_ima.index_of_point(p);
+ }
+
+ template <typename I>
+ inline
+ bool
+ closest_point_functor_with_indexes<I>::inqueue_p_wrt_input_p(const V& input_p)
+ {
+ return input_p == true;
+ }
+
+ template <typename I>
+ inline
+ void
+ closest_point_functor_with_indexes<I>::init_p(const P&)
+ {
+ }
+
+ template <typename I>
+ inline
+ bool
+ closest_point_functor_with_indexes<I>::inqueue_p_wrt_input_n(const V& input_n)
+ {
+ return input_n == false;
+ }
+
+ template <typename I>
+ inline
+ void closest_point_functor_with_indexes<I>::process(const P& p, const P& n)
+ {
+ cp_ima(n) = cp_ima(p);
+ }
+
+
+
+ template <typename I>
+ inline
+ void
+ closest_point_functor_with_indexes<I>::init_(const I& input)
+ {
+ init(input);
+ }
+
+ template <typename I>
+ inline
+ bool
+ closest_point_functor_with_indexes<I>::inqueue_p_wrt_input_p_(const V& input_p)
+ {
+ return input_p == true;
+ }
+
+ template <typename I>
+ inline
+ void closest_point_functor_with_indexes<I>::init_p_(unsigned)
+ {
+ }
+
+ template <typename I>
+ inline
+ bool
+ closest_point_functor_with_indexes<I>::inqueue_p_wrt_input_n_(const V& input_n)
+ {
+ return input_n == false;
+ }
+
+ template <typename I>
+ inline
+ void
+ closest_point_functor_with_indexes<I>::process_(unsigned p, unsigned n)
+ {
+ cp_ima.element(n) = cp_ima.element(p);
+ }
+
+
+ /// ///
+ /// closest_point_functor_with_sites ///
+ /// ///
+
+
+ template <typename I>
+ inline
+ closest_point_functor_with_sites<I>::closest_point_functor_with_sites()
+ {
+ }
+
+ template <typename I>
+ inline
+ void
+ closest_point_functor_with_sites<I>::init(const I& input)
+ {
+ initialize(cp_ima, input);
+ data::fill(cp_ima, literal::origin);
}
template <typename I>
inline
bool
- closest_point_functor<I>::inqueue_p_wrt_input_p(const V& input_p)
+ closest_point_functor_with_sites<I>::inqueue_p_wrt_input_p(const V& input_p)
{
return input_p == true;
}
@@ -108,26 +224,68 @@ namespace mln
template <typename I>
inline
void
- closest_point_functor<I>::init_p(const P&)
+ closest_point_functor_with_sites<I>::init_p(const P& p)
{
-// cp_ima(p) = p;
+ cp_ima(p) = p;
}
template <typename I>
inline
bool
- closest_point_functor<I>::inqueue_p_wrt_input_n(const V& input_n)
+ closest_point_functor_with_sites<I>::inqueue_p_wrt_input_n(const V& input_n)
{
return input_n == false;
}
template <typename I>
inline
- void closest_point_functor<I>::process(const P& p, const P& n)
+ void
+ closest_point_functor_with_sites<I>::process(const P& p, const P& n)
{
cp_ima(n) = cp_ima(p);
}
+
+
+ template <typename I>
+ inline
+ void
+ closest_point_functor_with_sites<I>::init_(const I& input)
+ {
+ init(input);
+ }
+
+ template <typename I>
+ inline
+ bool
+ closest_point_functor_with_sites<I>::inqueue_p_wrt_input_p_(const V& input_p)
+ {
+ return input_p == true;
+ }
+
+ template <typename I>
+ inline
+ void closest_point_functor_with_sites<I>::init_p_(unsigned p)
+ {
+ cp_ima.element(p) = cp_ima.point_at_index(p);
+ }
+
+ template <typename I>
+ inline
+ bool
+ closest_point_functor_with_sites<I>::inqueue_p_wrt_input_n_(const V& input_n)
+ {
+ return input_n == false;
+ }
+
+ template <typename I>
+ inline
+ void
+ closest_point_functor_with_sites<I>::process_(unsigned p, unsigned n)
+ {
+ cp_ima.element(n) = cp_ima.element(p);
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::transform::internal
diff --git a/milena/tests/Makefile.am b/milena/tests/Makefile.am
index 523af72..0e05a0f 100644
--- a/milena/tests/Makefile.am
+++ b/milena/tests/Makefile.am
@@ -41,6 +41,7 @@ SUBDIRS = \
topo \
trace \
trait \
+ transform \
unit_test \
util \
value \
diff --git a/milena/tests/transform/Makefile.am b/milena/tests/transform/Makefile.am
index 4ee9cfd..04087f7 100644
--- a/milena/tests/transform/Makefile.am
+++ b/milena/tests/transform/Makefile.am
@@ -4,14 +4,14 @@ include $(top_srcdir)/milena/tests/tests.mk
check_PROGRAMS = \
bench_closest_point_geodesic \
- closest_point_geodesic \
+ distance_and_closest_point_geodesic \
distance_front \
distance_geodesic \
influence_zone_front \
influence_zone_geodesic
bench_closest_point_geodesic_SOURCES = bench_closest_point_geodesic.cc
-closest_point_geodesic_SOURCES = closest_point_geodesic.cc
+distance_and_closest_point_geodesic_SOURCES = distance_and_closest_point_geodesic.cc
distance_front_SOURCES = distance_front.cc
distance_geodesic_SOURCES = distance_geodesic.cc
influence_zone_front_SOURCES = influence_zone_front.cc
diff --git a/milena/tests/transform/bench_closest_point_geodesic.cc b/milena/tests/transform/bench_closest_point_geodesic.cc
index 974a734..06a6b44 100644
--- a/milena/tests/transform/bench_closest_point_geodesic.cc
+++ b/milena/tests/transform/bench_closest_point_geodesic.cc
@@ -36,6 +36,7 @@
#include <mln/data/fill.hh>
#include <mln/opt/at.hh>
#include <mln/transform/closest_point_geodesic.hh>
+#include <mln/value/int_u8.hh>
int main()
diff --git a/milena/tests/transform/closest_point_geodesic.cc b/milena/tests/transform/closest_point_geodesic.cc
deleted file mode 100644
index c9bb97c..0000000
--- a/milena/tests/transform/closest_point_geodesic.cc
+++ /dev/null
@@ -1,54 +0,0 @@
-// 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. This exception does not however invalidate any other
-// reasons why the executable file might be covered by the GNU General
-// Public License.
-
-/// \file tests/transform/closest_point_geodesic.cc
-///
-/// Test on mln::transform::closest_point_geodesic.
-
-#include <mln/core/image/image2d.hh>
-#include <mln/core/alias/neighb2d.hh>
-#include <mln/value/int_u8.hh>
-#include <mln/data/fill.hh>
-#include <mln/debug/println.hh>
-#include <mln/opt/at.hh>
-
-#include <mln/transform/closest_point_geodesic.hh>
-
-
-int main()
-{
- using namespace mln;
- using value::int_u8;
-
- image2d<bool> input(9, 9);
- data::fill(input, false);
- opt::at(input, 2, 4) = true;
- opt::at(input, 4, 2) = true;
-
- image2d<point2d> output = transform::closest_point_geodesic(input, c4(), int_u8(4));
- debug::println(output);
-}
diff --git a/milena/tests/transform/distance_and_closest_point_geodesic.cc b/milena/tests/transform/distance_and_closest_point_geodesic.cc
new file mode 100644
index 0000000..d3544ab
--- /dev/null
+++ b/milena/tests/transform/distance_and_closest_point_geodesic.cc
@@ -0,0 +1,95 @@
+// Copyright (C) 2008, 2009 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.
+
+/// \file tests/transform/closest_point_geodesic.cc
+///
+/// Test on mln::transform::closest_point_geodesic.
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/data/fill.hh>
+#include <mln/debug/println.hh>
+#include <mln/opt/at.hh>
+#include <mln/level/compare.hh>
+
+#include <mln/transform/distance_and_closest_point_geodesic.hh>
+
+unsigned dmap_ref[] = { 4, 4, 4, 3, 2, 3, 4, 4, 4,
+ 4, 4, 3, 2, 1, 2, 3, 4, 4,
+ 4, 3, 2, 1, 0, 1, 2, 3, 4,
+ 3, 2, 1, 2, 1, 2, 3, 4, 4,
+ 2, 1, 0, 1, 2, 3, 4, 4, 4,
+ 3, 2, 1, 2, 3, 4, 4, 4, 4,
+ 4, 3, 2, 3, 4, 4, 4, 4, 4,
+ 4, 4, 3, 4, 4, 4, 4, 4, 4,
+ 4, 4, 4, 4, 4, 4, 4, 4, 4 };
+
+
+unsigned cp_idx_ref[] = { 0 , 0 , 82 , 82 , 82 , 82, 82, 0 , 0 ,
+ 0 , 82 , 82 , 82 , 82 , 82, 82, 82, 0 ,
+ 110, 82 , 82 , 82 , 82 , 82, 82, 82, 82,
+ 110, 110, 110, 82 , 82 , 82, 82, 82, 0 ,
+ 110, 110, 110, 110, 82 , 82, 82, 0 , 0 ,
+ 110, 110, 110, 110, 82 , 82, 0 , 0 , 0 ,
+ 110, 110, 110, 110, 110, 0 , 0 , 0 , 0 ,
+ 0 , 110, 110, 110, 0 , 0 , 0 , 0 , 0 ,
+ 0 , 0 , 110, 0 , 0 , 0 , 0 , 0 , 0 };
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ image2d<bool> input(9, 9);
+ data::fill(input, false);
+ opt::at(input, 2, 4) = true;
+ opt::at(input, 4, 2) = true;
+
+ {
+ typedef util::couple<image2d<int_u8>, image2d<point2d> > output_t;
+ output_t output = transform::distance_and_closest_point_geodesic(input,
+ c4(),
+ int_u8(4));
+ mln_assertion(output.first() == make::image2d(dmap_ref));
+ ///FIXME: test the closest point image here.
+ }
+
+ {
+ p_array<point2d> arr;
+ arr.insert(point2d(2, 4));
+ arr.insert(point2d(4, 2));
+ typedef util::couple<image2d<int_u8>, image2d<unsigned> > output_t;
+ output_t output = transform::distance_and_closest_point_geodesic(arr,
+ input.domain(),
+ c4(),
+ int_u8(4));
+ mln_assertion(output.first() == make::image2d(dmap_ref));
+ mln_assertion(output.second() == make::image2d(cp_idx_ref));
+ }
+}
--
1.5.6.5
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Fix missing tests in morpho.
* tests/morpho/top_hat.cc: New.
* tests/morpho/Makefile.am: Update.
* tests/morpho/closing/area.cc,
* tests/morpho/closing/height.cc (Copyright): Fix.
* tests/morpho/closing/structural.cc: New.
* tests/morpho/closing/Makefile.am: Update.
* tests/morpho/opening/volume.cc,
* tests/morpho/opening/area.cc,
* tests/morpho/opening/height.cc (Copyright): Fix.
* tests/morpho/opening/structural.cc: New.
* tests/morpho/opening/Makefile.am: Update.
Makefile.am | 12 ++++------
closing/Makefile.am | 2 +
closing/area.cc | 4 +--
closing/height.cc | 5 ++--
closing/structural.cc | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++
opening/Makefile.am | 2 +
opening/area.cc | 4 +--
opening/height.cc | 4 ++-
opening/structural.cc | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++
opening/volume.cc | 4 ++-
top_hat.cc | 24 ++++++++++----------
11 files changed, 152 insertions(+), 27 deletions(-)
Index: tests/morpho/top_hat.cc
--- tests/morpho/top_hat.cc (revision 3462)
+++ tests/morpho/top_hat.cc (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009 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
@@ -25,10 +26,9 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/morpho/elementary/top_hat.cc
- *
- * \brief Test on mln::morpho::elementary::top_hat's.
- */
+/// \file tests/morpho/elementary/top_hat.cc
+///
+/// Test on mln::morpho::top_hat.
#include <mln/core/image/image2d.hh>
#include <mln/core/alias/neighb2d.hh>
@@ -37,7 +37,7 @@
#include <mln/debug/iota.hh>
#include <mln/debug/println.hh>
-#include <mln/morpho/elementary/top_hat.hh>
+#include <mln/morpho/top_hat.hh>
int main()
@@ -51,15 +51,15 @@
debug::iota(ima);
debug::println(ima);
- debug::println( morpho::elementary::top_hat_white(ima, c4()) );
- debug::println( morpho::elementary::top_hat_black(ima, c4()) );
- debug::println( morpho::elementary::top_hat_self_complementary(ima, c4()) );
+ debug::println( morpho::top_hat_white(ima, c4().win()) );
+ debug::println( morpho::top_hat_black(ima, c4().win()) );
+ debug::println( morpho::top_hat_self_complementary(ima, c4().win()) );
image2d<bool> msk(3, 3, 0);
data::fill(msk, pw::value(ima) >= pw::cst(5u));
debug::println(msk);
- debug::println( morpho::elementary::top_hat_white(msk, c4()) );
- debug::println( morpho::elementary::top_hat_black(msk, c4()) );
- debug::println( morpho::elementary::top_hat_self_complementary(msk, c4()) );
+ debug::println( morpho::top_hat_white(msk, c4().win()) );
+ debug::println( morpho::top_hat_black(msk, c4().win()) );
+ debug::println( morpho::top_hat_self_complementary(msk, c4().win()) );
}
Property changes on: tests/morpho/top_hat.cc
___________________________________________________________________
Added: svn:mergeinfo
Index: tests/morpho/closing/Makefile.am
--- tests/morpho/closing/Makefile.am (revision 3463)
+++ tests/morpho/closing/Makefile.am (working copy)
@@ -8,6 +8,7 @@
height \
area \
volume \
+ structural \
sum
leveling_SOURCES = leveling.cc
@@ -15,6 +16,7 @@
height_SOURCES = height.cc
area_SOURCES = area.cc
volume_SOURCES = volume.cc
+structural_SOURCES = structural.cc
sum_SOURCES = sum.cc
TESTS = $(check_PROGRAMS)
Index: tests/morpho/closing/area.cc
--- tests/morpho/closing/area.cc (revision 3463)
+++ tests/morpho/closing/area.cc (working copy)
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2007, 2008, 2009 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
Index: tests/morpho/closing/height.cc
--- tests/morpho/closing/height.cc (revision 3463)
+++ tests/morpho/closing/height.cc (working copy)
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2007, 2008, 2009 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
@@ -41,6 +41,7 @@
#include "tests/data.hh"
+
int main()
{
using namespace mln;
Index: tests/morpho/closing/structural.cc
--- tests/morpho/closing/structural.cc (revision 0)
+++ tests/morpho/closing/structural.cc (revision 0)
@@ -0,0 +1,59 @@
+// Copyright (C) 2009 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.
+
+/// \file tests/morpho/closing/structural.cc
+///
+/// Test on mln::morpho::closing::structural.
+
+#include <mln/core/image/image2d.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/core/alias/window2d.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include <mln/morpho/closing/structural.hh>
+
+#include "tests/data.hh"
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ image2d<int_u8> lena, out;
+ io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
+
+ bool w[] = { 0, 1, 1,
+ 0, 0, 1,
+ 0, 0, 1 };
+
+ out = morpho::closing::structural(lena,
+ convert::to<window2d>(w));
+ io::pgm::save(out, "out.pgm");
+}
Index: tests/morpho/opening/Makefile.am
--- tests/morpho/opening/Makefile.am (revision 3463)
+++ tests/morpho/opening/Makefile.am (working copy)
@@ -8,6 +8,7 @@
height \
area \
volume \
+ structural \
sum
leveling_SOURCES = leveling.cc
@@ -15,6 +16,7 @@
height_SOURCES = height.cc
area_SOURCES = area.cc
volume_SOURCES = volume.cc
+structural_SOURCES = structural.cc
sum_SOURCES = sum.cc
TESTS = $(check_PROGRAMS)
Index: tests/morpho/opening/volume.cc
--- tests/morpho/opening/volume.cc (revision 3463)
+++ tests/morpho/opening/volume.cc (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009 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
@@ -40,6 +41,7 @@
#include "tests/data.hh"
+
int main()
{
using namespace mln;
Index: tests/morpho/opening/area.cc
--- tests/morpho/opening/area.cc (revision 3463)
+++ tests/morpho/opening/area.cc (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009 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
@@ -41,7 +42,6 @@
#include "tests/data.hh"
-
int main()
{
using namespace mln;
Index: tests/morpho/opening/height.cc
--- tests/morpho/opening/height.cc (revision 3463)
+++ tests/morpho/opening/height.cc (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009 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
@@ -40,6 +41,7 @@
#include "tests/data.hh"
+
int main()
{
using namespace mln;
Index: tests/morpho/opening/structural.cc
--- tests/morpho/opening/structural.cc (revision 0)
+++ tests/morpho/opening/structural.cc (revision 0)
@@ -0,0 +1,59 @@
+// Copyright (C) 2009 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.
+
+/// \file tests/morpho/opening/structural.cc
+///
+/// Test on mln::morpho::opening::structural.
+
+#include <mln/core/image/image2d.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/core/alias/window2d.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include <mln/morpho/opening/structural.hh>
+
+#include "tests/data.hh"
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ image2d<int_u8> lena, out;
+ io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
+
+ bool w[] = { 0, 1, 1,
+ 0, 0, 1,
+ 0, 0, 1 };
+
+ out = morpho::opening::structural(lena,
+ convert::to<window2d>(w));
+ io::pgm::save(out, "out.pgm");
+}
Index: tests/morpho/Makefile.am
--- tests/morpho/Makefile.am (revision 3463)
+++ tests/morpho/Makefile.am (working copy)
@@ -30,7 +30,9 @@
meyer_wst_long \
rank_filter \
skeleton_constrained \
- thinning
+ thinning \
+ top_hat
+
# -------------- #
# Normal tests. #
@@ -38,7 +40,6 @@
# FIXME: Have erosion and dilation perform symmetric tests.
erosion_SOURCES = erosion.cc
-
contrast_SOURCES = contrast.cc
general_SOURCES = general.cc
gradient_SOURCES = gradient.cc
@@ -48,21 +49,18 @@
graph_image_morpho_SOURCES = graph_image_morpho.cc
graph_image_wst_SOURCES = graph_image_wst.cc
-
line_graph_image_morpho_SOURCES = line_graph_image_morpho.cc
line_graph_image_wst_SOURCES = line_graph_image_wst.cc
-
complex_image_morpho_SOURCES = complex_image_morpho.cc
complex_image_wst_SOURCES = complex_image_wst.cc
meyer_wst_SOURCES = meyer_wst.cc
-
rank_filter_SOURCES = rank_filter.cc
-
skeleton_constrained_SOURCES = skeleton_constrained.cc
-
+top_hat_SOURCES = top_hat.cc
combined_SOURCES = combined.cc
+
# --------------- #
# Complex tests. #
# --------------- #