https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Make the gaussian filter work using algebra::vec.
* mln/linear/gaussian.hh: use algebra::vec.
* mln/io/pnm/load.hh: comments.
* sandbox/jardonnet/test/Makefile: test.
* sandbox/jardonnet/test/gaussian.cc: test.
* sandbox/jardonnet/TODO: New.
* sandbox/jardonnet/icc.txt: New.
mln/binarization/thresholding.hh | 1
mln/io/pnm/load.hh | 3 +-
mln/linear/gaussian.hh | 39 +++++++++++++++++++++++++++-------
sandbox/jardonnet/TODO | 10 ++++++++
sandbox/jardonnet/icc.txt | 2 +
sandbox/jardonnet/registration/icp.hh | 13 ++++-------
sandbox/jardonnet/test/Makefile | 3 ++
sandbox/jardonnet/test/gaussian.cc | 21 ++++++++++++++++++
tests/binarization/thresholding.cc | 18 ++++++++++++---
9 files changed, 90 insertions(+), 20 deletions(-)
Index: tests/binarization/thresholding.cc
--- tests/binarization/thresholding.cc (revision 1780)
+++ tests/binarization/thresholding.cc (working copy)
@@ -38,6 +38,7 @@
#include <mln/level/all.hh>
#include <mln/io/pgm/load.hh>
+#include <mln/io/ppm/load.hh>
#include <mln/io/pbm/save.hh>
//#include "tests/data.hh"
@@ -47,10 +48,19 @@
using namespace mln;
using value::int_u8;
- typedef image2d<int_u8> I;
-
- I lena;
+ {
+ image2d<int_u8> lena;
io::pgm::load(lena, "../../img/lena.pgm");
-
io::pbm::save(binarization::thresholding(lena, argc), "out1.pgm");
}
+
+ {
+ image2d<int_u8> l;
+ image2d<int> lena;
+ io::pgm::load(l, "../../img/lena.pgm");
+
+ level::paste(l, lena);
+
+ io::pbm::save(binarization::thresholding(lena, argc), "out2.pgm");
+ }
+}
Index: mln/linear/gaussian.hh
--- mln/linear/gaussian.hh (revision 1780)
+++ mln/linear/gaussian.hh (working copy)
@@ -1,4 +1,3 @@
-
// Copyright (C) 2001, 2002, 2003, 2004 EPITA Research and Development
// Laboratory
//
@@ -41,6 +40,8 @@
# include <mln/geom/ncols.hh>
# include <mln/geom/nrows.hh>
+# include <mln/algebra/vec.hh>
+
# include <vector>
# include <cmath>
@@ -209,7 +210,7 @@
// Non causal part
- tmp2[len - 1] = 0;
+ tmp2[len - 1] = WorkType(); // FIXME : = 0, literal::zero ...?
tmp2[len - 2] =
c.nm[1] * ima(finish);
@@ -260,7 +261,7 @@
// Apply on rows.
for (unsigned j = 0; j < geom::ncols(img); ++j)
- recursivefilter_<float>(img, coef,
+ recursivefilter_< mln_value(I) >(img, coef,
make::point2d(-img.border(), j),
make::point2d(geom::nrows(img) - 1 + img.border(), j),
geom::nrows(img) + 2 * img.border(),
@@ -268,7 +269,7 @@
// Apply on columns.
for (unsigned i = 0; i < geom::nrows(img); ++i)
- recursivefilter_<float>(img, coef,
+ recursivefilter_< mln_value(I) >(img, coef,
make::point2d(i, -img.border()),
make::point2d(i, geom::ncols(img) - 1 + img.border()),
geom::ncols(img) + 2 * img.border(),
@@ -280,7 +281,8 @@
template <class I, class F, class O>
inline
void
- gaussian_common_(const Image<I>& in,
+ gaussian_common_(trait::value::nature::scalar,
+ const Image<I>& in,
const F& coef,
float sigma,
Image<O>& out)
@@ -298,6 +300,25 @@
level::paste(work_img, out);
}
+
+ template <class I, class F, class O>
+ inline
+ void
+ gaussian_common_(trait::value::nature::vectorial,
+ const Image<I>& in,
+ const F& coef,
+ float sigma,
+ Image<O>& out)
+ {
+ // typedef algebra::vec<3, float> vec3f;
+ // mln_ch_value(O, vec3f) work_img(exact(in).domain());
+ // FIXME : paste does not work (rgb8 -> vec3f).
+ level::paste(in, out);
+
+ if (sigma > 0.006)
+ gaussian_(out, coef);
+ }
+
} // end of namespace mln::linear::impl
// Facade.
@@ -306,15 +327,19 @@
inline
void
gaussian(const Image<I>& input, float sigma,
- Image<O>& output)
+ Image<O>& out)
{
+ mln_precondition(exact(input).has_data());
+ mln_precondition(exact(output).has_data());
+
impl::recursivefilter_coef_
coef(1.68f, 3.735f,
1.783f, 1.723f,
-0.6803f, -0.2598f,
0.6318f, 1.997f,
sigma);
- impl::gaussian_common_(input, coef, sigma, output);
+ impl::gaussian_common_(mln_trait_value_nature(mln_value(I))(),
+ input, coef, sigma, out);
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/binarization/thresholding.hh
--- mln/binarization/thresholding.hh (revision 1780)
+++ mln/binarization/thresholding.hh (working copy)
@@ -66,6 +66,7 @@
thresholding(const Image<I>& input, const mln_value(I) threshold)
{
trace::entering("binarization::thresholding");
+
mln_precondition(exact(input).has_data());
mlc_is(mln_trait_value_nature(mln_value(I)),
trait::value::nature::scalar)::check();
Index: mln/io/pnm/load.hh
--- mln/io/pnm/load.hh (revision 1780)
+++ mln/io/pnm/load.hh (working copy)
@@ -76,13 +76,14 @@
v.blue() = c;
}
+
//read a scalar value (sizeof(int_u8) != 1)
template <class V>
inline
void read_value(std::ifstream& file,
V& v)
{
- typedef typename V::enc E;
+ typedef typename V::enc E; // FIXME : if V = int
E c;
file.read((char*)(&c), sizeof(E));
Index: sandbox/jardonnet/test/Makefile
--- sandbox/jardonnet/test/Makefile (revision 1780)
+++ sandbox/jardonnet/test/Makefile (working copy)
@@ -10,5 +10,8 @@
gsub:
g++ gaussian_subsampling.cc $(FLAG) -o '+gsub.exe'
+gau:
+ g++ gaussian.cc $(FLAG) -o '+gau.exe'
+
run:
time ./+sub.exe . . ; time ./+gsub.exe . .
\ No newline at end of file
Index: sandbox/jardonnet/test/gaussian.cc
--- sandbox/jardonnet/test/gaussian.cc (revision 0)
+++ sandbox/jardonnet/test/gaussian.cc (revision 0)
@@ -0,0 +1,21 @@
+#include <mln/core/image2d.hh>
+
+#include <mln/io/ppm/load.hh>
+#include <mln/io/ppm/save.hh>
+
+#include <mln/linear/gaussian.hh>
+
+#include <mln/algebra/vec.hh>
+
+int main(int, char*)
+{
+ using namespace mln;
+
+ image2d< value::rgb8 > img;
+ io::ppm::load(img, "../../../img/lena.ppm");
+ image2d< value::rgb8 > out(img.domain());
+
+ linear::gaussian(img, .5, out);
+
+ io::ppm::save(out, "./+gau.ppm");
+}
Index: sandbox/jardonnet/TODO
--- sandbox/jardonnet/TODO (revision 0)
+++ sandbox/jardonnet/TODO (revision 0)
@@ -0,0 +1,10 @@
+image2d< value::rgb8 >
+
+img == out
+
+- - - - - - - - - -
+gaussian.cc: In function 'int main(int, char*)':
+gaussian.cc:22: error: no match for 'operator==' in 'img == out'
+
+
+*/*/*/*/*/*/*/*
\ No newline at end of file
Index: sandbox/jardonnet/registration/icp.hh
--- sandbox/jardonnet/registration/icp.hh (revision 1780)
+++ sandbox/jardonnet/registration/icp.hh (working copy)
@@ -46,7 +46,7 @@
*
*
*/
- template <typename I>
+ template <typename I, template J>
inline
void
icp(const Image<I>& cloud,
@@ -57,8 +57,6 @@
namespace impl
{
- //FIXME : add version for every image types.
-
template <typename I, typename J>
inline
void
@@ -74,18 +72,16 @@
quat old_qk, qk;
unsigned int k;
-
k = 0;
Pk = P;
do {
//projection
old_qk = qk;
-
//qk = match(P, mu_P, Xk, mu_Xk);
// error =
-
+ ++k;
} while (k < 3 || (qk - old_qk).sqr_norm() > epsilon);
@@ -95,6 +91,7 @@
} // end of namespace mln::registration::impl
+ // this version could convert image cloud in a vector of point?
template <typename I, typename J>
inline
void
@@ -105,13 +102,13 @@
mln_precondition(exact(cloud).has_data());
mln_precondition(exact(surface).has_data());
+
+
output = impl::icp_(exact(cloud), exact(surface));
trace::exiting("registration::icp");
}
- //cloud == image ?
-
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::registration
Index: sandbox/jardonnet/icc.txt
--- sandbox/jardonnet/icc.txt (revision 0)
+++ sandbox/jardonnet/icc.txt (revision 0)
@@ -0,0 +1,2 @@
+export GXX_INCLUDE=/usr/include/c++/4.1
+-D_GLIBCXX_GTHREAD_USE_WEAK=0