* tests/fun/x2x/rotation.cc: Check if the sites which are part of the
rotated image are part of the original image _domain_. Call
domain().has() instead of has().
Interpolated sites which were part of the domain needed a larger
extension in order to be computed correctly.
---
milena/ChangeLog | 10 ++++++++++
milena/tests/fun/x2x/rotation.cc | 19 +++++++++++--------
2 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index d08a017..74d2d1f 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,15 @@
2009-01-09 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Fix fun::x2x::rotation test.
+
+ * tests/fun/x2x/rotation.cc: Check if the sites which are part of the
+ rotated image are part of the original image _domain_. Call
+ domain().has() instead of has().
+ Interpolated sites which were part of the domain needed a larger
+ extension in order to be computed correctly.
+
+2009-01-09 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Fix level::stretch.
* mln/level/stretch.hh: Use double variables instead of float because
diff --git a/milena/tests/fun/x2x/rotation.cc b/milena/tests/fun/x2x/rotation.cc
index 7835ac9..b96c551 100644
--- a/milena/tests/fun/x2x/rotation.cc
+++ b/milena/tests/fun/x2x/rotation.cc
@@ -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
@@ -39,6 +40,7 @@
#include <mln/core/image/interpolated.hh>
#include <mln/make/vec.hh>
#include <mln/fun/x2v/bilinear.hh>
+#include <mln/extension/adjust.hh>
#include "tests/data.hh"
@@ -51,21 +53,22 @@ int main()
algebra::vec<2,float> axis;
axis[0] = 0;
axis[1] = 1;
-
- image2d<int_u8> lena;
+ typedef image2d<int_u8> ima_t;
+ ima_t lena;
io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
- image2d<int_u8> out(lena.domain());
- interpolated<image2d<int_u8>, fun::x2v::bilinear> inter(lena);
+ ima_t out;
+ initialize(out, lena);
- fun::x2x::rotation<2,float> rot1(0.1, axis);
+ interpolated<ima_t, fun::x2v::bilinear> inter(lena);
- mln_piter_(image2d<int_u8>) p(out.domain());
+ fun::x2x::rotation<2,float> rot1(0.1, axis);
+ mln_piter_(ima_t) p(out.domain());
for_all(p)
{
algebra::vec<2,float> v = rot1.inv()(p.to_site().to_vec());
- if (inter.has(v))
+ if (inter.domain().has(v))
out(p) = inter(v);
else
out(p) = 255;
--
1.5.6.5
* mln/level/stretch.hh: Use double variables instead of float because
of precision issues. See ticket #179.
---
milena/ChangeLog | 7 +++++++
milena/mln/level/stretch.hh | 16 ++++++++++------
2 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 6364251..d08a017 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,12 @@
2009-01-09 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Fix level::stretch.
+
+ * mln/level/stretch.hh: Use double variables instead of float because
+ of precision issues. See ticket #179.
+
+2009-01-09 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Add from_double_to_value dispatch in from_to.
* mln/convert/from_to.hxx: add more forward declarations.
diff --git a/milena/mln/level/stretch.hh b/milena/mln/level/stretch.hh
index e91dbe7..80190b4 100644
--- a/milena/mln/level/stretch.hh
+++ b/milena/mln/level/stretch.hh
@@ -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
@@ -44,6 +44,8 @@
# include <mln/level/transform.hh>
+# include <mln/value/internal/encoding.hh>
+# include <iomanip>
namespace mln
{
@@ -84,21 +86,23 @@ namespace mln
estim::min_max(input, min_, max_);
if (max_ != min_)
{
- float
+ //FIXME: we would like to use float instead of double but we
+ //can't for precision reasons. See ticket #179.
+ double
min = float(min_),
max = float(max_),
epsilon = mln_epsilon(float),
- m = 0.0f - 0.5f + epsilon,
M = mln_max(V) + 0.5f - epsilon,
+ m = 0.0f - 0.5f + epsilon,
a = (M - m) / (max - min),
b = (m * max - M * min) / (max - min);
- fun::v2v::linear<float, float, V> f(a, b);
+ fun::v2v::linear<double, double, V> f(a, b);
output = level::transform(input, f);
}
else
{
initialize(output, input);
- // trace::warning("output has no significative data!");
+ trace::warning("output has no significative data!");
}
trace::exiting("level::impl::stretch");
--
1.5.6.5
* mln/convert/from_to.hxx: add more forward declarations.
* mln/convert/impl/all.hh: include from_double_to_value.hh.
* mln/convert/impl/from_double_to_value.hh: new file. Add a new
dispatch for double conversion.
---
milena/ChangeLog | 11 ++
milena/mln/convert/from_to.hxx | 13 ++
milena/mln/convert/impl/all.hh | 1 +
milena/mln/convert/impl/from_double_to_value.hh | 157 +++++++++++++++++++++++
4 files changed, 182 insertions(+), 0 deletions(-)
create mode 100644 milena/mln/convert/impl/from_double_to_value.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 2a5fb87..6364251 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,16 @@
2009-01-09 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Add from_double_to_value dispatch in from_to.
+
+ * mln/convert/from_to.hxx: add more forward declarations.
+
+ * mln/convert/impl/all.hh: include from_double_to_value.hh.
+
+ * mln/convert/impl/from_double_to_value.hh: new file. Add a new
+ dispatch for double conversion.
+
+2009-01-09 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Remove a useless test in level/median.
* tests/level/Makefile.am,
diff --git a/milena/mln/convert/from_to.hxx b/milena/mln/convert/from_to.hxx
index 793da8b..e2cbe3d 100644
--- a/milena/mln/convert/from_to.hxx
+++ b/milena/mln/convert/from_to.hxx
@@ -194,6 +194,19 @@ namespace mln
void
from_to_(const Value<F>& from, Value<T>& to);
+ // double-> Value
+ template <typename V>
+ void
+ from_to_(const double& from, Value<V>& to);
+
+ // double-> unsigned
+ void
+ from_to_(const double& from, unsigned& to);
+
+ // double-> int
+ void
+ from_to_(const double& from, int& to);
+
// float -> Value
template <typename V>
void
diff --git a/milena/mln/convert/impl/all.hh b/milena/mln/convert/impl/all.hh
index a7ef79b..1a33732 100644
--- a/milena/mln/convert/impl/all.hh
+++ b/milena/mln/convert/impl/all.hh
@@ -33,6 +33,7 @@
/// File that includes all from-to conversion routines.
+# include <mln/convert/impl/from_double_to_value.hh>
# include <mln/convert/impl/from_float_to_value.hh>
# include <mln/convert/impl/from_image_to_site_set.hh>
# include <mln/convert/impl/from_int_to_value.hh>
diff --git a/milena/mln/convert/impl/from_double_to_value.hh b/milena/mln/convert/impl/from_double_to_value.hh
new file mode 100644
index 0000000..fc1d23e
--- /dev/null
+++ b/milena/mln/convert/impl/from_double_to_value.hh
@@ -0,0 +1,157 @@
+// 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.
+
+#ifndef MLN_CONVERT_IMPL_FROM_DOUBLE_TO_VALUE_HH
+# define MLN_CONVERT_IMPL_FROM_DOUBLE_TO_VALUE_HH
+
+/// \file mln/convert/impl/from_double_to_value.hh
+///
+/// General conversion procedure from a double to a value.
+///
+/// \todo Augment code + add checks.
+
+# include <utility>
+# include <mln/value/concept/integer.hh>
+# include <mln/value/concept/floating.hh>
+# include <mln/core/concept/value.hh>
+# include <mln/math/round.hh>
+
+
+
+
+namespace mln
+{
+
+ namespace convert
+ {
+
+ /// Conversion of a double \p from towards a value \p to.
+ template <typename V>
+ void
+ from_to(const double& from, Value<V>& to);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ // Case 1:
+
+ template <typename V>
+ inline
+ void
+ from_double_to_value(const double& from,
+ mln::value::Integer<V>& to)
+ {
+ exact(to) = math::round<V>()(from);
+ }
+
+ // Case 2:
+
+ template <typename V>
+ inline
+ void
+ from_double_to_value(const double& from,
+ mln::value::Floating<V>& to)
+ {
+ exact(to) = from;
+ }
+
+
+ // Default: no conversion defined.
+
+ template <typename V>
+ inline
+ void
+ from_double_to_value(const double& from,
+ Value<V>& to)
+ {
+ mlc_abort(V)::check();
+ }
+
+ } // end of namespace mln::convert::impl
+
+
+ namespace internal
+ {
+
+ template <typename V>
+ inline
+ void
+ from_double_to_value_dispatch(const double& from, Value<V>& to)
+ {
+ impl::from_double_to_value(from, exact(to));
+ }
+
+ } // end of namespace mln::convert::internal
+
+
+ namespace over_load
+ {
+
+ // Facades.
+
+
+ // double-> Value
+ template <typename V>
+ inline
+ void
+ from_to_(const double& from, Value<V>& to)
+ {
+ internal::from_double_to_value_dispatch(from, to);
+ }
+
+ // double-> unsigned
+ inline
+ void
+ from_to_(const double& from,
+ unsigned& to)
+ {
+ mln_precondition(from >= 0);
+ to = math::round<unsigned>()(from);
+ }
+
+ // double-> int
+ inline
+ void
+ from_to_(const double& from,
+ int& to)
+ {
+ to = math::round<int>()(from);
+ }
+
+ } // end of namespace mln::convert::over_load
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::convert
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CONVERT_IMPL_FROM_DOUBLE_TO_VALUE_HH
--
1.5.6.5
#176: Fix override of center_at() in graph and complex iterators
---------------------+------------------------------------------------------
Reporter: lazzara | Owner: Olena Team
Type: defect | Status: new
Priority: major | Milestone:
Component: Milena | Version: 1.0
Keywords: |
---------------------+------------------------------------------------------
Graph and complex iterators inherit from site_relative_iterator_base.
site_relative_iterator_base provides center_at() but do not allow derived
classes to implement their own.
Graph and complex iterators need to update an underlying iterator while
calling center_at() which is not possible currently, except by overriding
center_at().
We may add the following call in site_relative_iterator_base::center_at():
exact(this)->center_at_();
And rename center_at() to center_at_() in the following files:
- mln/core/image/graph_window_piter.hh
- mln/core/image/complex_neighborhood_piter.hh
--
Ticket URL: <https://trac.lrde.org/olena/ticket/176>
Olena <http://olena.lrde.epita.fr>
Olena, a generic and efficient C++ image processing library.
* mln/core/dpsites_piter.hh,
* mln/core/neighb.hh,
* mln/win/multiple_size.hh: remove empty implementation of center_at_().
* mln/core/image/complex_neighborhood_piter.hh: add a new line.
* mln/core/internal/site_relative_iterator_base.hh: add default
implementation of center_at_().
---
milena/ChangeLog | 14 ++++++++++
milena/mln/core/dpsites_piter.hh | 28 +------------------
.../mln/core/image/complex_neighborhood_piter.hh | 4 ++-
.../core/internal/site_relative_iterator_base.hh | 16 ++++++++++-
milena/mln/core/neighb.hh | 28 +------------------
milena/mln/win/multiple_size.hh | 15 +---------
6 files changed, 38 insertions(+), 67 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 4696e60..61a8e60 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,17 @@
+2009-01-09 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Provide a default implementation of center_at_() in
+ site_relative_iterator_base.
+
+ * mln/core/dpsites_piter.hh,
+ * mln/core/neighb.hh,
+ * mln/win/multiple_size.hh: remove empty implementation of center_at_().
+
+ * mln/core/image/complex_neighborhood_piter.hh: add a new line.
+
+ * mln/core/internal/site_relative_iterator_base.hh: add default
+ implementation of center_at_().
+
2009-01-08 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Cleanup level approx median.
diff --git a/milena/mln/core/dpsites_piter.hh b/milena/mln/core/dpsites_piter.hh
index 91709d7..b2cd978 100644
--- a/milena/mln/core/dpsites_piter.hh
+++ b/milena/mln/core/dpsites_piter.hh
@@ -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
@@ -74,10 +74,6 @@ namespace mln
/// Go to the next point.
void do_next_();
- /// Set the reference psite.
- template <typename Pref>
- void center_at_(const Pref&);
-
/// Compute the current psite.
mln_psite(V) compute_p_() const;
@@ -120,10 +116,6 @@ namespace mln
/// Go to the next point.
void do_next_();
- /// Do some work while setting the reference site.
- template <typename Pref>
- void center_at_(const Pref&);
-
/// Compute the current psite.
mln_psite(V) compute_p_() const;
@@ -187,14 +179,6 @@ namespace mln
}
template <typename V>
- template <typename Pref>
- inline
- void
- dpsites_fwd_piter<V>::center_at_(const Pref&)
- {
- }
-
- template <typename V>
inline
mln_psite(V)
dpsites_fwd_piter<V>::compute_p_() const
@@ -253,14 +237,6 @@ namespace mln
}
template <typename V>
- template <typename Pref>
- inline
- void
- dpsites_bkd_piter<V>::center_at_(const Pref&)
- {
- }
-
- template <typename V>
inline
mln_psite(V)
dpsites_bkd_piter<V>::compute_p_() const
diff --git a/milena/mln/core/image/complex_neighborhood_piter.hh b/milena/mln/core/image/complex_neighborhood_piter.hh
index 0a91f30..32beda6 100644
--- a/milena/mln/core/image/complex_neighborhood_piter.hh
+++ b/milena/mln/core/image/complex_neighborhood_piter.hh
@@ -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
@@ -90,6 +91,7 @@ namespace mln
/// Set the reference psite.
template <typename Pref>
void center_at_(const Pref& c);
+
/// Compute the current psite.
psite compute_p_() const;
/// \}
diff --git a/milena/mln/core/internal/site_relative_iterator_base.hh b/milena/mln/core/internal/site_relative_iterator_base.hh
index 7a662b6..ffa5c33 100644
--- a/milena/mln/core/internal/site_relative_iterator_base.hh
+++ b/milena/mln/core/internal/site_relative_iterator_base.hh
@@ -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
@@ -112,6 +113,11 @@ namespace mln
private:
+ // Allows inherited classes to do extra work while centering.
+ // Default implementation.
+ template <typename P>
+ void center_at_(const P& c);
+
/// The psite designated by this iterator.
mln_psite(S) p_;
};
@@ -228,6 +234,14 @@ namespace mln
return exact(*this);
}
+ template <typename S, typename E>
+ template <typename P>
+ inline
+ void
+ site_relative_iterator_base<S,E>::center_at_(const P& c)
+ {
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::internal
diff --git a/milena/mln/core/neighb.hh b/milena/mln/core/neighb.hh
index d509af0..d5f0e83 100644
--- a/milena/mln/core/neighb.hh
+++ b/milena/mln/core/neighb.hh
@@ -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
@@ -140,10 +140,6 @@ namespace mln
/// Go to the next point.
void do_next_();
- /// Do some work while centering the iterator.
- template <typename Pref>
- void center_at_(const Pref&);
-
/// Compute the current psite.
mln_psite(W) compute_p_() const;
@@ -182,10 +178,6 @@ public:
/// Go to the next point.
void do_next_();
- /// Do some work while centering the iterator.
- template <typename Pref>
- void center_at_(const Pref&);
-
/// Compute the current psite.
mln_psite(W) compute_p_() const;
@@ -318,14 +310,6 @@ protected:
}
template <typename W>
- template <typename Pref>
- inline
- void
- neighb_fwd_niter<W>::center_at_(const Pref&)
- {
- }
-
- template <typename W>
inline
mln_psite(W)
neighb_fwd_niter<W>::compute_p_() const
@@ -386,14 +370,6 @@ protected:
}
template <typename W>
- template <typename Pref>
- inline
- void
- neighb_bkd_niter<W>::center_at_(const Pref&)
- {
- }
-
- template <typename W>
inline
mln_psite(W)
neighb_bkd_niter<W>::compute_p_() const
diff --git a/milena/mln/win/multiple_size.hh b/milena/mln/win/multiple_size.hh
index 86ccaed..8760b9c 100644
--- a/milena/mln/win/multiple_size.hh
+++ b/milena/mln/win/multiple_size.hh
@@ -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
@@ -155,10 +156,6 @@ namespace mln
/// Go to the next point.
void do_next_();
- /// Do some work while setting the reference site.
- template <typename Pref>
- void center_at_(const Pref&);
-
/// Compute the current psite.
mln_psite(W) compute_p_() const;
@@ -353,14 +350,6 @@ namespace mln
}
template <unsigned n, typename W, typename F>
- template <typename Pref>
- inline
- void
- multiple_size_qiter<n,W,F>::center_at_(const Pref&)
- {
- }
-
- template <unsigned n, typename W, typename F>
inline
mln_psite(W)
multiple_size_qiter<n,W,F>::compute_p_() const
--
1.5.6.5
* samples/fill-proto.cc.raw: new file. Inline code inserted in tutorial.
* samples/tuto4_genericity_and_algorithms.cc: Add more code.
* tutorial.tex: add more details. Explain the code.
---
milena/ChangeLog | 10 +
milena/doc/tutorial/samples/fill-proto.cc.raw | 7 +
.../samples/tuto4_genericity_and_algorithms.cc | 13 ++
milena/doc/tutorial/tutorial.tex | 181 +++++++++++++++++---
4 files changed, 183 insertions(+), 28 deletions(-)
create mode 100644 milena/doc/tutorial/samples/fill-proto.cc.raw
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 9472f63..e9d3d63 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,13 @@
+2009-01-08 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Add more details in step 4 in tutorial.
+
+ * samples/fill-proto.cc.raw: new file. Inline code inserted in tutorial.
+
+ * samples/tuto4_genericity_and_algorithms.cc: Add more code.
+
+ * tutorial.tex: add more details. Explain the code.
+
2009-01-06 Guillaume Lazzara <z(a)lrde.epita.fr>
Add fun::meta::green and fun::meta::blue.
diff --git a/milena/doc/tutorial/samples/fill-proto.cc.raw b/milena/doc/tutorial/samples/fill-proto.cc.raw
new file mode 100644
index 0000000..f0bd0fe
--- /dev/null
+++ b/milena/doc/tutorial/samples/fill-proto.cc.raw
@@ -0,0 +1,7 @@
+namespace data
+{
+
+ template <typename I, typename D>
+ void fill(Image<I>& ima, const D& data);
+
+}
diff --git a/milena/doc/tutorial/samples/tuto4_genericity_and_algorithms.cc b/milena/doc/tutorial/samples/tuto4_genericity_and_algorithms.cc
index ca5e7f4..1c80453 100644
--- a/milena/doc/tutorial/samples/tuto4_genericity_and_algorithms.cc
+++ b/milena/doc/tutorial/samples/tuto4_genericity_and_algorithms.cc
@@ -36,6 +36,19 @@ int main()
lena = duplicate(lena_bak);
// \{
+ p_array<point2d> arr;
+ for (def::coord row = geom::min_row(lena); row < geom::max_row(lena); ++row)
+ for (def::coord col = geom::min_row(lena); col < geom::max_col(lena); ++col)
+ if (((row + col) % 2) == 0)
+ arr.append(point2d(row, col));
+ // \}
+ // \{
+ for (def::coord row = geom::min_row(lena); row < geom::max_row(lena); ++row)
+ for (def::coord col = geom::min_row(lena); col < geom::max_col(lena); ++col)
+ if (((row + col) % 2) == 0)
+ opt::at(lena, row, col) = literal::green;
+ // \}
+ // \{
data::fill((lena | fun::p2b::chess()).rw(), literal::green);
// \}
doc::ppmsave(lena, "tuto4_genericity_and_algorithms");
diff --git a/milena/doc/tutorial/tutorial.tex b/milena/doc/tutorial/tutorial.tex
index d3aca8e..8cae3af 100644
--- a/milena/doc/tutorial/tutorial.tex
+++ b/milena/doc/tutorial/tutorial.tex
@@ -58,6 +58,7 @@
% #1 : section name
% #2 : section title
\newcommand{\doxysection}[2]{%
+\vspace{1cm}
\label{#1}
\backslash endhtmlonly%
\backslash section #1 #2%
@@ -302,14 +303,14 @@ $$
\backslash endhtmlonly
\backslash page tutorial Tutorial
-- \backslash subpage tutoforeword
-- \backslash subpage loadnsave
-- \backslash subpage tutofirstimage
-- \backslash subpage tutochangeimage
-- \backslash subpage tutogenericity
-- \backslash subpage tutoconvimage
-- \backslash subpage tutowinneighb
-- \backslash subpage tutograph
+- \backslash subpage tuto0
+- \backslash subpage tuto1
+- \backslash subpage tuto2
+- \backslash subpage tuto3
+- \backslash subpage tuto4
+- \backslash subpage tuto5
+- \backslash subpage tuto6
+- \backslash subpage tuto7
\backslash page quickref Quick Reference Guide
- \backslash subpage installation
@@ -323,6 +324,7 @@ $$
- \backslash subpage imamemmgmt
- \backslash subpage basicops
- \backslash subpage graphandima
+- \backslash subpage functions
- \backslash subpage arithmops
- \backslash subpage mathtools
- \backslash subpage debugtools
@@ -350,19 +352,19 @@ A copy of the license is provided in the file COPYING.DOC.
\begin{htmlonly}
%====================================
-\doxychapter{tutoforeword}{Step 0: Foreword}
+\doxychapter{tuto0}{Step 0: Foreword}
- image2d
- typical use case
\begin{center}%
- \hspace{1cm} Go to \doxyref{loadnsave}~ \longrightarrow%
+ \hspace{1cm} Go to \doxyref{tuto1}~ \longrightarrow%
\end{center}%
%====================================
-\doxychapter{loadnsave}{Step 1: Load and save images}
+\doxychapter{tuto1}{Step 1: Load and save images}
After this step you shoud know how to:
\begin{itemize}
@@ -396,12 +398,12 @@ The supported file formats and their associated image value types are listed
in section \doxyref{imaio}.
\vspace{2cm}
-\tutotoc{tutoforeword}{tutofirstimage}
+\tutotoc{tuto0}{tuto2}
%====================================
-\doxychapter{tutofirstimage}{Step 2: Create your first image}
+\doxychapter{tuto2}{Step 2: Create your first image}
After this step you should know how to:
\begin{itemize}
@@ -409,7 +411,7 @@ After this step you should know how to:
\item display an image in console mode.
\end{itemize}
-\doxysee{tuto2_first_image.cc}.
+\doxysee{tuto2_first_image.cc}
\vspace{2cm}
@@ -444,12 +446,12 @@ though. A more detailed description can be found in section
\vspace{2cm}
\begin{center}
- \tutotoc{loadnsave}{tutochangeimage}
+ \tutotoc{tuto1}{tuto3}
\end{center}
%====================================
-\doxychapter{tutochangeimage}{Step 3: Read and write images}
+\doxychapter{tuto3}{Step 3: Read and write images}
After this step you should know how to:
\begin{itemize}
@@ -458,7 +460,7 @@ After this step you should know how to:
\end{itemize}
-\doxysee{tuto3_rw_image.cc}.
+\doxysee{tuto3_rw_image.cc}
\vspace{2cm}
First create an empty color image with a \var{box2d} of 40x40 as domain.
@@ -499,12 +501,12 @@ the reference guide.
\vspace{2cm}
\begin{center}
- \tutotoc{tutofirstimage}{tutogenericity}
+ \tutotoc{tuto2}{tuto4}
\end{center}
%====================================
-\doxychapter{tutogenericity}{Step 4: Genericity and algorithms}
+\doxychapter{tuto4}{Step 4: Regions of interest}
After this step you should know how to:
\begin{itemize}
@@ -512,14 +514,55 @@ After this step you should know how to:
\item work only on a region of interest in an image.
\end{itemize}
-\doxysee{tuto4_genericity_and_algorithms.cc}.
+\doxysee{tuto4_genericity_and_algorithms.cc}
\vspace{2cm}
+In the previous step, we used the routine \code{data::fill} in order to change
+the values of an image. It was convenient since we did not need to write any
+loop by hand. The problem was that we could not specificy which region to fill
+with data. This point leads us to talk about the genericity in Olena.
+All along this example we will use the routine \code{data::fill} to illustrate
+the possibilities in Olena but note that every image types passed to the
+routine in this example could be passed to any algorithm in the library
+expecting an image.
+
+One main feature of Olena is to be able to easily work on regions of interest in
+images. According to the way a region of interest is defined, a specific image
+type is associated. Therefore, each algorithm knows exactly what it is working
+on and can behave differently in order to be the most efficient as possible.
+
+
+All along this step, we will use the following image \var{lena} declared as
+follow:
+
\doxycode[1]{tuto4_genericity_and_algorithms}
\doxyimg{small-enlarged}
+\code{data::fill} has the following prototype:
+\doxyrawcode{fill-proto}
+So keep in mind that the first argument we will try to construct in each
+example is an image. Note that this image \must be writable, e.g. non-const.
+
+
+%**************************
+\doxysection{tuto4imadomainsiteset}{Image domain restricted by a site set}
+
+Here, we would like to fill a small square with green in \var{lena}. We want
+this square to be of size 20x20 and to be located at (20,20).
+First, we just need to declare this square which is actually a site set, a
+\type{box2d}.
\doxycode[2]{tuto4_genericity_and_algorithms}
+
+Then, we just need to tell \code{data::fill} that we would like to fill the
+image \var{lena} but only in this restricted part of the image domain.
\doxycode[3]{tuto4_genericity_and_algorithms}
+Operator '|' can be read 'restricted to'. So below, we wrote 'image \var{lena}
+restricted to the region of interest \var{roi}'. Actually this is not directly
+\var{lena} which is restricted but its domain.
+
+Note the use of \code{rw()} which is mandatory due to C++ limitations. In C++,
+the image created by \code{lena | roi} is \code{const}, e.g. read-only, though
+\code{data::fill} expect a \code{non-const} image, e.g. read-write.
\begin{center}
\begin{tabular}{c c c}
@@ -530,7 +573,21 @@ After this step you should know how to:
\end{center}
+%**************************
+\doxysection{tuto4imadomainfun}{Image domain restricted by a function}
+
+Sometimes it may not be easy to construct a site set to restrict an image. For
+instance, if we would like to fill with green one point out of two in the whole
+image, we \textbf{do not want} to write anyloop or construct any site set by hand:
\doxycode[4]{tuto4_genericity_and_algorithms}
+\doxycode[5]{tuto4_genericity_and_algorithms}
+
+A shorter way to get exactly the same result, is to define that behavior by a
+function. In Milena, a function \code{fun::p2v::chess} is available and does
+exactly what we want. Like if it was a site set, simply restrict the image with
+the function.
+
+\doxycode[6]{tuto4_genericity_and_algorithms}
\begin{center}
\begin{tabular}{c c c}
\doxyimg{small-enlarged} & ~\huge{\rightarrow}~ & \doxyfigure[2]{tuto4_genericity_and_algorithms}{3cm} \\
@@ -539,9 +596,41 @@ After this step you should know how to:
\end{tabular}
\end{center}
+Note that the functions provided by default in Olena are actually functors.
+Thus, they must be constructed like any object which why it is written
+\code{lena | fun::p2v::chess()} and not \code{lena | fun::p2v::chess}.
+
+
+FIXME: Talk about C functions once it is possible in Milena.
+
+
+%**************************
+\doxysection{tuto4imadomainmask}{Image domain restricted by a mask}
+
+Sometimes instead of having a site site or a function defining the regions of
+interest we want to work on, we may have a binary image, e.g. a mask. When a
+site has its value set to true, it means it will be considered as part of the
+masked image domain. Otherwise, it will not.
+
+We construct a mask, \var{mask}. It is initialized with the same geometry properties as
+\var{lena}
+(domain, extension...).
+\doxycode[7]{tuto4_genericity_and_algorithms}
+
+Then, we cannot restrict directly \var{lena} with \var{mask}. These two images
+have the same domain, so \code{lena | mask.domain()} would not do anything.
+\var{mask} is a classical image, there is not specific type for mask images.
+Therefore, we need to express that we want that binary image to be considered as
+a mask.
+\doxycode[8]{tuto4_genericity_and_algorithms}
+\code{pw::value(mask)} makes explicit the fact that \var{mask} is actually a
+mask. It means, that for each site of \var{mask}, if its value is set to
+\val{true}, then the value associated to this site in \var{lena} must be set
+to green.
+In this example, we use two images for two different use case: \var{lena} store
+the result and the modifications make by the algorithm and \var{mask} allows the
+algorithm to know whether it must treat a site or not.
-\doxycode[5]{tuto4_genericity_and_algorithms}
-\doxycode[6]{tuto4_genericity_and_algorithms}
\begin{center}
\begin{tabular}{c c c c}
\doxyimg{small-enlarged} &
@@ -553,8 +642,34 @@ After this step you should know how to:
\end{tabular}
\end{center}
-\doxycode[7]{tuto4_genericity_and_algorithms}
-\doxycode[8]{tuto4_genericity_and_algorithms}
+
+%**************************
+\doxysection{tuto4imadomainpredicate}{Image domain restricted by a predicate}
+
+Restricting by a predicate is exactly like restricting with a function. We want
+to talk about that separately in order to present the small routines available.
+They enable the user to write quick and efficient predicate/function.
+
+The two routines are :
+\begin{itemize}
+ \item pw::value(Image), as seen in a previous section, it is a way to express
+ 'for each site value in Image'.
+ \item pw::cst(Value), it is a way to specify a value to which a site value can
+ be compared.
+\end{itemize}
+
+Let's see a common use case.
+First, we binarize lena according to specific criterions, only site values with
+specific colors are set to true in \var{lena_bw}. Others are set to false. This
+image will be used in order to label the components.
+Let's consider a labeled image \var{label}. Each component of \var{lena} is labeled with a unique index.
+Now, we consider that that our region of interest is a component with id 16.
+Then we want to express 'for each site \var{fill} its value in \var{lena} if its
+value in \var{label} is equal to 16'.
+\doxycode[9]{tuto4_genericity_and_algorithms}
+
+
+\doxycode[10]{tuto4_genericity_and_algorithms}
\begin{center}
\begin{tabular}{c c c c}
@@ -571,19 +686,19 @@ After this step you should know how to:
\vspace{2cm}
\begin{center}
- \tutotoc{tutochangeimage}{tutoconvimage}
+ \tutotoc{tuto3}{tuto5}
\end{center}
%====================================
-\doxychapter{tutoconvimage}{Step 5: Conversion between image values}
+\doxychapter{tuto5}{Step 5: Conversion between image values}
%====================================
-\doxychapter{tutowinneighb}{Step 6: Using structural elements with algorithms}
+\doxychapter{tuto6}{Step 6: Using structural elements with algorithms}
%====================================
-\doxychapter{tutograph}{Step 7: Handle graphes with an image}
+\doxychapter{tuto7}{Step 7: Handle graphes with an image}
\end{htmlonly}
@@ -595,6 +710,7 @@ After this step you should know how to:
\doxysection{requirements}{Requirements}
+%----------------
\doxysubsection{compexample}{To compile the user examples}
\begin{itemize}
@@ -605,6 +721,7 @@ After this step you should know how to:
+%----------------
\doxysubsection{compdoc}{To compile the documentation (Optional)}
\begin{itemize}
@@ -616,6 +733,7 @@ After this step you should know how to:
\item the `texinfo' utilities from GNU
\end{itemize}
+%----------------
\doxysubsection{devolena}{To develop in Olena}
\begin{itemize}
\item GNU Autotools (Autoconf 2.54, Automake 1.10)
@@ -2228,6 +2346,13 @@ Output:
%====================================
\newpage
\clearpage
+\doxychapter{functions}{Functions}
+
+FIXME write it
+
+%====================================
+\newpage
+\clearpage
\doxychapter{arithmops}{Arithmetical operators}
FIXME write it
--
1.5.6.5