https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Fix Registration. Add tests.
Add tests:
* tests/registration: New.
* tests/registration/Makefile.am: New.
* tests/registration/registration.cc: New.
Fix Registration:
* mln/core/image/lazy_image.hh: Fix lvalue.
* mln/fun/x2p/closest_point.hh: Fix input type.
* mln/registration/icp.hh: Fix center()
* mln/registration/get_rtransf.hh,
* mln/registration/internal/rms.hh: Fix point->vec convertions.
mln/core/image/lazy_image.hh | 33 +++++++++++++++++++----
mln/fun/x2p/closest_point.hh | 8 ++---
mln/registration/get_rtransf.hh | 3 +-
mln/registration/icp.hh | 7 ++--
mln/registration/internal/rms.hh | 9 ++++--
tests/registration/Makefile.am | 10 +++++++
tests/registration/registration.cc | 52 +++++++++++++++++++++++++++++++++++++
7 files changed, 106 insertions(+), 16 deletions(-)
Index: tests/registration/Makefile.am
--- tests/registration/Makefile.am (revision 0)
+++ tests/registration/Makefile.am (revision 0)
@@ -0,0 +1,10 @@
+## Process this file through Automake to create Makefile.in -*- Makefile -*-
+
+include $(top_srcdir)/milena/tests/tests.mk
+
+check_PROGRAMS = \
+ registration
+
+registration_SOURCES = registration.cc
+
+TESTS = $(check_PROGRAMS)
Index: tests/registration/registration.cc
--- tests/registration/registration.cc (revision 0)
+++ tests/registration/registration.cc (revision 0)
@@ -0,0 +1,52 @@
+// 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.
+
+/*! \file tests/registration/registration.cc
+ *
+ * \brief Test on mln::registration::registration.cc
+ */
+
+#include <mln/io/pbm/all.hh>
+
+#include "registration.hh"
+#include "multiscale.hh"
+#include "icp.hh"
+
+
+int main(int argc, char ** argv)
+{
+ using namespace mln;
+
+ image2d< bool > img1;
+ image2d< bool > img2;
+
+ //load images
+ io::pbm::load(img1, argv[1]);
+ io::pbm::load(img2, argv[2]);
+
+ registration::registration(img1,img2);
+}
Index: mln/core/image/lazy_image.hh
--- mln/core/image/lazy_image.hh (revision 2637)
+++ mln/core/image/lazy_image.hh (working copy)
@@ -102,7 +102,7 @@
typedef mln_result(F) rvalue;
/// Return type of read-write access.
- typedef mln_result(F)& lvalue;
+ typedef mln_result(F) lvalue;
/// Skeleton.
typedef lazy_image< tag::image_<I>, F, B > skeleton;
@@ -125,11 +125,18 @@
/// Test if a pixel value is accessible at \p p.
bool has(const mln_psite(I)&) const;
+ /// Read-only access of pixel value at F::input \p x.
+ mln_result(F) operator()(const typename F::input& x) const;
+
+ /// Read and "write if possible" access of pixel value at F::input \p x.
+ mln_result(F) operator()(const typename F::input& x);
+
/// Read-only access of pixel value at point site \p p.
- mln_result(F) operator()(const mln_psite(I)& p) const;
+ rvalue operator()(const mln_psite(I)& p) const;
/// Read and "write if possible" access of pixel value at point site \p p.
lvalue operator()(const mln_psite(I)& p);
+
};
@@ -174,7 +181,7 @@
template <typename I, typename F, typename B>
inline
mln_result(F)
- lazy_image<I,F,B>::operator()(const mln_psite(I)& p) const
+ lazy_image<I,F,B>::operator()(const typename F::input& p) const
{
mln_assertion(this->has(p));
if (this->data_->is_known(p))
@@ -187,8 +194,8 @@
template <typename I, typename F, typename B>
inline
- typename lazy_image<I,F,B>::lvalue
- lazy_image<I,F,B>::operator()(const mln_psite(I)& p)
+ mln_result(F)
+ lazy_image<I,F,B>::operator()(const typename F::input& p)
{
mln_assertion(this->has(p));
if (this->data_->is_known(p))
@@ -200,6 +207,22 @@
template <typename I, typename F, typename B>
inline
+ typename lazy_image<I,F,B>::rvalue
+ lazy_image<I,F,B>::operator()(const mln_psite(I)& p) const
+ {
+ return (*this).operator()(convert::to< typename F::input >(p));
+ }
+
+ template <typename I, typename F, typename B>
+ inline
+ typename lazy_image<I,F,B>::lvalue
+ lazy_image<I,F,B>::operator()(const mln_psite(I)& p)
+ {
+ return (*this).operator()(convert::to< typename F::input >(p));
+ }
+
+ template <typename I, typename F, typename B>
+ inline
const box2d&
lazy_image<I,F,B>::domain() const
{
Index: mln/fun/x2p/closest_point.hh
--- mln/fun/x2p/closest_point.hh (revision 2637)
+++ mln/fun/x2p/closest_point.hh (working copy)
@@ -45,7 +45,7 @@
template <typename P>
struct closest_point
{
- typedef const algebra::vec<P::dim, float>& input;
+ typedef algebra::vec<P::dim, float> input;
typedef P result;
closest_point(const p_array<P>& X, const box<P>& box)
@@ -56,16 +56,16 @@
result
//inline
- operator () (const algebra::vec<P::dim, float>& Ck) const
+ operator () (const input& Ck) const
{
++log_functor_call;
algebra::vec<P::dim,float> Cki = Ck;
- algebra::vec<P::dim,float> best_x = X[0];
+ algebra::vec<P::dim,float> best_x = convert::to<
algebra::vec<P::dim,float> >(X[0]);
float best_d = norm::l2(Cki - best_x);
for (unsigned j = 1; j < X.nsites(); ++j)
{
- algebra::vec<P::dim,float> Xj = X[j];
+ algebra::vec<P::dim,float> Xj = convert::to<
algebra::vec<P::dim,float> >(X[j]);
float d = norm::l2(Cki - Xj);
if (d < best_d)
{
Index: mln/morpho/closing_attribute.hh
Index: mln/registration/icp.hh
--- mln/registration/icp.hh (revision 2637)
+++ mln/registration/icp.hh (working copy)
@@ -121,13 +121,14 @@
// FIXME: Move elsewhere
template <typename P>
- P center(const p_array<P>& a)
+ algebra::vec<P::dim,float>
+ center(const p_array<P>& a)
{
algebra::vec<P::dim,float> c(literal::zero);
for (unsigned i = 0; i < a.nsites(); ++i)
c += convert::to< algebra::vec<P::dim,float> > (a[i]);
- return algebra::to_point<P>(c / a.nsites());
+ return c / a.nsites();
}
// FIXME: Make use of level::apply
@@ -137,7 +138,7 @@
p_array<P>& b)
{
for (unsigned i = 0; i < a.nsites(); i++)
- b[i] = f(a[i]);
+ b[i] = f(convert::to< algebra::vec<P::dim,float> >(a[i]));
}
Index: mln/registration/get_rtransf.hh
--- mln/registration/get_rtransf.hh (revision 2637)
+++ mln/registration/get_rtransf.hh (working copy)
@@ -61,7 +61,8 @@
//mu_xk = center map(Ck)
algebra::vec<P::dim,float> mu_xk(literal::zero);
for (unsigned i = 0; i < c.nsites(); ++i)
- mu_xk += convert::to< algebra::vec<P::dim,float> >(map(ck[i]));
+ mu_xk += convert::to< algebra::vec<P::dim,float> >(map(
+ convert::to<
algebra::vec<P::dim,float> >(ck[i])));
mu_xk /= c.nsites();
// qR
Index: mln/registration/internal/rms.hh
--- mln/registration/internal/rms.hh (revision 2637)
+++ mln/registration/internal/rms.hh (working copy)
@@ -58,9 +58,12 @@
float f = 0.f;
for (unsigned i = 0; i < a.nsites(); ++i)
{
- algebra::vec<P::dim,float> a2f = q2(a[i]);
- algebra::vec<P::dim,float> a1f =
map(algebra::to_point<P>(q1(a[i])));
- f += norm::l2(a1f - a2f);
+ algebra::vec<P::dim,float> a2f = convert::to<
algebra::vec<P::dim,float> >(a[i]);
+ algebra::vec<P::dim,float> a1f =
+ convert::to< algebra::vec<P::dim,float> > \
+ (map(q1(convert::to< algebra::vec<P::dim,float> >(a[i]))));
+
+ f += norm::l2(a1f - q2(a2f));
}
return f / a.nsites();
}