2991: Fix registration test. Add multiscale test.

https://svn.lrde.epita.fr/svn/oln/trunk/milena Index: ChangeLog from Ugo Jardonnet <ugo.jardonnet@lrde.epita.fr> Fix registration test. Add multiscale test. * tests/registration/multiscale.cc: Add this test. * tests/registration/registration.cc: Fix this one. * mln/registration/multiscale.hh: Pseudo fix it. * mln/registration/registration.hh: Fix it. * mln/registration/icp.hh: Fix signature. mln/registration/icp.hh | 2 - mln/registration/multiscale.hh | 46 +++++++++++++++++++++++++++++++- mln/registration/registration.hh | 1 tests/registration/multiscale.cc | 52 +++++++++++++++++++++++++++++++++++++ tests/registration/registration.cc | 13 +++------ 5 files changed, 102 insertions(+), 12 deletions(-) Index: tests/registration/multiscale.cc --- tests/registration/multiscale.cc (revision 0) +++ tests/registration/multiscale.cc (revision 0) @@ -0,0 +1,52 @@ +// 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/registration/registration.cc + * + * \brief Test on mln::registration::registration.cc + */ + +#include <mln/io/pbm/all.hh> + +#include <mln/registration/multiscale.hh> + + +int main() +{ + using namespace mln; + + image2d< bool > img1; + image2d< bool > img2; + + //load images + io::pbm::load(img1, MLN_IMG_DIR "/lena.pbm"); + io::pbm::load(img2, MLN_IMG_DIR "/lena.pbm"); + + //FIXME: Auto test result + //FIXME: Make it pass + registration::multiscale(img1,img2, 5, 2); +} Index: tests/registration/registration.cc --- tests/registration/registration.cc (revision 2990) +++ tests/registration/registration.cc (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE) +// 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 @@ -31,11 +31,7 @@ */ #include <mln/io/pbm/all.hh> - -#include "registration.hh" -#include "multiscale.hh" -#include "icp.hh" - +#include <mln/registration/registration.hh> int main(int argc, char ** argv) { @@ -45,8 +41,9 @@ image2d< bool > img2; //load images - io::pbm::load(img1, argv[1]); - io::pbm::load(img2, argv[2]); + io::pbm::load(img1, MLN_IMG_DIR "/lena.pbm"); + io::pbm::load(img2, MLN_IMG_DIR "/lena.pbm"); registration::registration(img1,img2); + //FIXME: Auto test result } Index: mln/registration/multiscale.hh --- mln/registration/multiscale.hh (revision 2990) +++ mln/registration/multiscale.hh (working copy) @@ -32,7 +32,6 @@ # include <mln/core/image/lazy_image.hh> # include <mln/core/site_set/p_array.hh> # include <mln/registration/icp.hh> -# include <mln/registration/registration.hh> # include <mln/fun/x2p/closest_point.hh> namespace mln @@ -55,6 +54,49 @@ namespace impl { + // FIXME: move elsewhere + template <typename P> + void shuffle(p_array<P>& a) + { + for (unsigned int i = 0; i < a.nsites(); i++) + { + unsigned int r = rand() % a.nsites(); + P tmp; + tmp = a[i]; + a[i] = a[r]; + a[r] = tmp; + } + } + + template <typename P> + box<P> bigger(const box<P>& a, const box<P>& b) + { + P pmin,pmax; + + for (unsigned i = 0; i < P::dim; i++) + { + pmin[i] = (a.pmin()[i] < b.pmin()[i]) ? a.pmin()[i] : b.pmin()[i]; + pmax[i] = (a.pmax()[i] > b.pmax()[i]) ? a.pmax()[i] : b.pmax()[i]; + } + + return box<P>(pmin, pmax); + } + + template <typename P> + inline + box<P> //dif + enlarge(const box<P>& box, unsigned b) + { + mln::box<P> nbox(box); + + for (unsigned i = 0; i < P::dim; ++i) + { + nbox.pmin()[i] -= b; + nbox.pmax()[i] += b; + } + return nbox; + } + template <typename I, typename J> inline composed< rotation<I::site::dim, float>, translation<I::site::dim, float> > @@ -86,7 +128,7 @@ { unsigned l = cloud.nsites() / std::pow(q, e); l = (l<1) ? 1 : l; - impl::registration_(cloud, map, qk, l, 1e-3); + registration::impl::icp_(cloud, l, map, qk, 1e-3); } return qk; } Index: mln/registration/registration.hh --- mln/registration/registration.hh (revision 2990) +++ mln/registration/registration.hh (working copy) @@ -83,7 +83,6 @@ lazy_image<I, fun::x2p::closest_point<mln_psite(I)>, box2d> map(fun, fun.domain()); - //run registration return registration::icp(c, map, 1e-3); Index: mln/registration/icp.hh --- mln/registration/icp.hh (revision 2990) +++ mln/registration/icp.hh (working copy) @@ -215,7 +215,7 @@ T& qk, const float epsilon = 1e-3) { - impl::icp_(c, map, qk, c_length, epsilon); + impl::icp_(c, c_length, map, qk, epsilon); } # endif // ! MLN_INCLUDE_ONLY
participants (1)
-
Ugo Jardonnet