https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Add big_chess functor.
* mln/fun/p2b/big_chess.hh: Add this functor.
big_chess.hh | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 95 insertions(+)
Index: mln/fun/p2b/big_chess.hh
--- mln/fun/p2b/big_chess.hh (revision 0)
+++ mln/fun/p2b/big_chess.hh (revision 0)
@@ -0,0 +1,95 @@
+// 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_FUN_P2B_BIG_CHESS_HH
+# define MLN_FUN_P2B_BIG_CHESS_HH
+
+/*! \file mln/fun/p2b/big_chess.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/function.hh>
+# include <mln/core/alias/point2d.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace p2b
+ {
+
+ // FIXME: Doc!
+ template <typename B>
+ struct big_chess : public Function_p2b< big_chess<B> >
+ {
+ typedef bool result;
+ typedef mln_psite(B) P;
+
+ big_chess(const B& box, const unsigned div);
+
+ bool operator()(const P& p) const;
+
+ const B& box;
+ const unsigned div;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template < typename B>
+ big_chess<B>::big_chess(const B& box, const unsigned div)
+ : box(box), div(div)
+ {
+ }
+
+ template < typename B>
+ inline
+ bool
+ big_chess<B>::operator()(const P& p) const
+ {
+ mln_coord(P) ret = 0;
+
+ for (short i = 0; i < P::dim; i++)
+ ret += p[i] / ((box.pmax()[i] - 1) / div);
+
+ return ret % 2;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::p2b
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_P2B_BIG_CHESS_HH
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)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
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Add mirror function.
* mln/fun/p2p: Add p2p function.
* mln/fun/p2p/mirror.hh: Revert first dim.
* mln/accu/maj_h.hh: default value.
accu/maj_h.hh | 2 +
fun/p2p/mirror.hh | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 86 insertions(+)
Index: mln/accu/maj_h.hh
--- mln/accu/maj_h.hh (revision 2989)
+++ mln/accu/maj_h.hh (working copy)
@@ -118,6 +118,8 @@
{
init();
valid_ = true;
+ //FIXME: Not generic
+ t_ = literal::zero;
}
template <typename T>
Index: mln/fun/p2p/mirror.hh
--- mln/fun/p2p/mirror.hh (revision 0)
+++ mln/fun/p2p/mirror.hh (revision 0)
@@ -0,0 +1,84 @@
+// 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_FUN_P2P_MIRROR_HH
+# define MLN_FUN_P2P_MIRROR_HH
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace p2p
+ {
+
+ template <typename B>
+ struct mirror : public Function_p2p< mirror<B> >
+ {
+ typedef mln_psite(B) result;
+
+ mirror(const B& box);
+
+ mln_psite(B)
+ operator()(const mln_psite(B)&) const;
+
+ const B& box_;
+ };
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename B>
+ inline
+ mirror<B>::mirror(const B& box)
+ : box_(box)
+ {
+ }
+
+ template <typename B>
+ inline
+ mln_psite(B)
+ mirror<B>::operator()(const mln_psite(B)& p) const
+ {
+ mln_precondition(box_.has(p));
+
+ mln_psite(B) r(p);
+ r[0] = box_.max()[0] - p[0];
+
+ return r;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::p2p
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+#endif /* MLN_FUN_P2P_MIRROR_HH */
+