Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- 9625 discussions
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Make subdirectory histo ready for rereading.
* tests/histo/compute.cc: Activate code.
Remove debug code.
* mln/trait/value_.hh (mln_value_card_from_): Fix macro.
* mln/histo/compute.hh: Split file contents with...
* mln/histo/compute.spe.hh: ...this new file.
* mln/value/int_s.hh (card, max): Fix definitions.
mln/histo/compute.hh | 28 ++++++++++-------
mln/histo/compute.spe.hh | 50 ++++++++++++-------------------
mln/trait/value_.hh | 4 +-
mln/value/int_s.hh | 4 +-
tests/histo/compute.cc | 74 ++++++++++++++++++++---------------------------
5 files changed, 73 insertions(+), 87 deletions(-)
Index: tests/histo/compute.cc
--- tests/histo/compute.cc (revision 1527)
+++ tests/histo/compute.cc (working copy)
@@ -48,57 +48,49 @@
using namespace mln;
using value::int_u8;
-// // Test on 'bool'.
-// {
-// accu::histo< value::set<bool> > h;
-
-// for (unsigned i = 0; i < 5; ++i)
-// h.take(false);
-// for (unsigned i = 0; i < 2; ++i)
-// h.take(true);
-// h.untake(true);
-
-// mln_assertion(h[0] * 10 + h[1] = 51);
-// mln_assertion(h(false) * 10 + h(true) = 51);
-// }
-
-// // Test on 'int_u8'.
-// {
-// image2d<int_u8> ima(3, 3);
-// debug::iota(ima);
-// ima.at(0,0) = 2;
-
-// histo::data< value::set<int_u8> > h = histo::compute(ima);
-// std::ostringstream oss;
-// oss << h;
-// mln_assertion(oss.str() = "2:2 3:1 4:1 5:1 6:1 7:1 8:1 9:1 ");
-
-// int_u8 i = 2;
-// mln_assertion(h(i) = 2);
-// }
+ // Test on 'bool'.
+ {
+ accu::histo< value::set<bool> > h;
+
+ for (unsigned i = 0; i < 5; ++i)
+ h.take(false);
+ for (unsigned i = 0; i < 2; ++i)
+ h.take(true);
+ h.untake(true);
+
+ mln_assertion(h[0] * 10 + h[1] = 51);
+ mln_assertion(h(false) * 10 + h(true) = 51);
+ }
- // Test on 'int_s5'.
+ // Test on 'int_u8'.
{
- typedef value::int_s<5> int_s5;
- image2d<int_s5> ima(3, 3);
+ image2d<int_u8> ima(3, 3);
debug::iota(ima);
ima.at(0,0) = 2;
- std::cout << "int_s5: "
- << value::props< int_s5 >::min() << ' '
- << value::props< int_s5 >::max() << ' '
- << value::props< int_s5 >::card_ << std::endl;
+ histo::data< value::set<int_u8> > h = histo::compute(ima);
+ std::ostringstream oss;
+ oss << h;
+ mln_assertion(oss.str() = "2:2 3:1 4:1 5:1 6:1 7:1 8:1 9:1 ");
- debug::println(ima);
+ int_u8 i = 2;
+ mln_assertion(h(i) = 2);
+ }
+ // Test on 'int_s5'; the value set is { -15, .., -1, 0, 1, .., 15 }
+ // the corresponding indices are: 0 .. 14 15 16 .. 30
+ {
+ typedef value::int_s<5> int_s5;
+ image2d<int_s5> ima(3, 3);
+ debug::iota(ima);
histo::data< value::set<int_s5> > h = histo::compute(ima);
- std::cout << "nvalues = " << h.vset().nvalues() << std::endl;
- std::cout << h << std::endl;
+ mln_assertion(h.vset().nvalues() = 31);
- for (unsigned i = 0; i < h.vset().nvalues(); ++i)
- std::cout << i << ':' << h[i] << ' ';
- std::cout << std::endl;
+ for (unsigned i = 0; i <= 15; ++i) // values from -15 to 0
+ mln_assertion(h[i] = 0);
+ for (unsigned i = 25; i <= 30; ++i) // values from 10 to 15
+ mln_assertion(h[i] = 0);
}
}
Index: mln/trait/value_.hh
--- mln/trait/value_.hh (revision 1527)
+++ mln/trait/value_.hh (working copy)
@@ -68,10 +68,10 @@
mln::trait::value::quant::low)
# define mln_value_card_from_(N) \
- N <= 16 \
+ (N <= 16 \
? mlc_pow_int((N <= 16 ? 2 : 1), \
(N <= 16 ? N : 1)) \
- : 0
+ : 0)
Index: mln/histo/compute.spe.hh
--- mln/histo/compute.spe.hh (revision 1524)
+++ mln/histo/compute.spe.hh (working copy)
@@ -25,17 +25,16 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_HISTO_COMPUTE_HH
-# define MLN_HISTO_COMPUTE_HH
+#ifndef MLN_HISTO_COMPUTE_SPE_HH
+# define MLN_HISTO_COMPUTE_SPE_HH
-/*! \file mln/histo/compute.hh
+/*! \file mln/histo/compute.spe.hh
*
- * \brief Routine to compute an histogram.
+ * \brief Specializations of histogram computation.
*/
-# include <mln/core/concept/image.hh>
-# include <mln/histo/data.hh>
+# ifndef MLN_INCLUDE_ONLY
namespace mln
{
@@ -43,28 +42,25 @@
namespace histo
{
- /// Compute the histogram of image \p input.
- template <typename I>
- data<mln_vset(I)> compute(const Image<I>& input);
-
-
-# ifndef MLN_INCLUDE_ONLY
-
namespace impl
{
+ namespace generic
+ {
template <typename I>
- data<mln_vset(I)> compute(trait::image::speed::any, const I& input)
+ data<mln_vset(I)> compute_(const I& input);
+ }
+
+ template <typename I>
+ data<mln_vset(I)>
+ compute_(trait::image::speed::any, const I& input)
{
- data<mln_vset(I)> h(input.values());
- mln_piter(I) p(input.domain());
- for_all(p)
- ++h(input(p));
- return h;
+ return generic::compute_(input);
}
template <typename I>
- data<mln_vset(I)> compute(trait::image::speed::fastest, const I& input)
+ data<mln_vset(I)>
+ compute_(trait::image::speed::fastest, const I& input)
{
data<mln_vset(I)> h(input.values());
mln_pixter(const I) p(input);
@@ -75,19 +71,11 @@
} // end of namespace mln::histo::impl
-
- template <typename I>
- data<mln_vset(I)> compute(const Image<I>& input)
- {
- mln_precondition(exact(input).has_data());
- return impl::compute(mln_trait_image_speed(I)(), exact(input));
- }
-
-# endif // ! MLN_INCLUDE_ONLY
-
} // end of namespace mln::histo
} // end of namespace mln
+# endif // ! MLN_INCLUDE_ONLY
+
-#endif // ! MLN_HISTO_COMPUTE_HH
+#endif // ! MLN_HISTO_COMPUTE_SPE_HH
Index: mln/histo/compute.hh
--- mln/histo/compute.hh (revision 1527)
+++ mln/histo/compute.hh (working copy)
@@ -37,6 +37,10 @@
# include <mln/histo/data.hh>
+// Specializations are in:
+# include <mln/histo/compute.spe.hh>
+
+
namespace mln
{
@@ -53,8 +57,11 @@
namespace impl
{
+ namespace generic
+ {
+
template <typename I>
- data<mln_vset(I)> compute(trait::image::speed::any, const I& input)
+ data<mln_vset(I)> compute_(const I& input)
{
data<mln_vset(I)> h(input.values());
mln_piter(I) p(input.domain());
@@ -63,15 +70,7 @@
return h;
}
- template <typename I>
- data<mln_vset(I)> compute(trait::image::speed::fastest, const I& input)
- {
- data<mln_vset(I)> h(input.values());
- mln_pixter(const I) p(input);
- for_all(p)
- ++h(p.val());
- return h;
- }
+ } // end of namespace mln::histo::impl::generic
} // end of namespace mln::histo::impl
@@ -79,8 +78,15 @@
template <typename I>
data<mln_vset(I)> compute(const Image<I>& input)
{
+ trace::entering("histo::compute");
+ mlc_equal(mln_trait_image_quant(I), mln::trait::image::quant::low)::check();
mln_precondition(exact(input).has_data());
- return impl::compute(mln_trait_image_speed(I)(), exact(input));
+
+ data<mln_vset(I)> h = impl::compute_(mln_trait_image_speed(I)(),
+ exact(input));
+
+ trace::exiting("histo::compute");
+ return h;
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/value/int_s.hh
--- mln/value/int_s.hh (revision 1527)
+++ mln/value/int_s.hh (working copy)
@@ -77,14 +77,14 @@
enum {
nbits = n,
- card = mln_value_card_from_(n)
+ card = mln_value_card_from_(n) - 1
};
typedef trait::value::nature::integer nature;
typedef trait::value::kind::data kind;
typedef mln_value_quant_from_(card) quant;
- static const self_ max() { return card / 2 - 1; }
+ static const self_ max() { return mln_value_card_from_(n) / 2 - 1; }
static const self_ min() { return - max(); }
static const self_ epsilon() { return 0; }
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-23 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Fix compile for fill level.
* fill.cc: Remove mln/value/props.hh.
---
fill.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: trunk/milena/tests/level/fill.cc
===================================================================
--- trunk/milena/tests/level/fill.cc (revision 1526)
+++ trunk/milena/tests/level/fill.cc (revision 1527)
@@ -35,7 +35,7 @@
#include <mln/level/fill.hh>
#include <mln/debug/println.hh>
-#include <mln/value/props.hh>
+//#include <mln/value/props.hh>
int main()
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk
ChangeLog:
2007-11-23 Simon Nivault <simon.nivault(a)lrde.epita.fr>
Remove creation of makefile in tests/make.
* configure.ac: Delete makefile.
---
configure.ac | 1 -
1 file changed, 1 deletion(-)
Index: trunk/configure.ac
===================================================================
--- trunk/configure.ac (revision 1525)
+++ trunk/configure.ac (revision 1526)
@@ -137,7 +137,6 @@
milena/tests/value/Makefile
milena/tests/value/concept/Makefile
milena/tests/value/builtin/Makefile
- milena/tests/make/Makefile
milena/tests/convert/Makefile
milena/tests/estim/Makefile
milena/tests/pw/Makefile
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-23 Simon Nivault <simon.nivault(a)lrde.epita.fr>
Remove useless tests on make.
* tests/make/Makefile.am: Remove.
* tests/make: Remove.
* tests/make_image2d.cc: Remove.
---
0 files changed
Index: trunk/milena/tests/make_image2d.cc (deleted)
===================================================================
--
--
Simon NIVAULT aka Pollux
EPITA 2009 - stagiaire LRDE milena
@ : simonnivault(a)hotmail.com
"La derision est l'ultime defi au malheur"
1
0
23 Nov '07
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-23 Simon Nivault <simon.nivault(a)lrde.epita.fr>
Add documentation and make some better tests.
* mln/core/h_mat.hh,
* mln/core/h_vec.hh,
* mln/core/image_if.hh,
* mln/core/image_if_interval.hh,
* mln/core/image_if_value.hh,
* mln/core/tr_image.hh,
* mln/core/tr_mesh.hh,
* mln/fun/x2x/composed.hh,
* mln/fun/x2x/rotation.hh,
* mln/fun/x2x/translation.hh: Add Documentation.
* tests/image_if_interval.cc,
* tests/image_if_value.cc,
* tests/line_piter.cc: Better tests.
---
mln/core/h_mat.hh | 30 +++++++++++++++++++-----------
mln/core/h_vec.hh | 11 +++++++----
mln/core/image_if.hh | 6 +++++-
mln/core/image_if_interval.hh | 7 ++++++-
mln/core/image_if_value.hh | 7 +++++--
mln/core/tr_image.hh | 3 ++-
mln/core/tr_mesh.hh | 1 +
mln/fun/x2x/composed.hh | 15 ++++++++++++++-
mln/fun/x2x/rotation.hh | 7 +++++++
mln/fun/x2x/translation.hh | 6 ++++++
tests/image_if_interval.cc | 7 +++++++
tests/image_if_value.cc | 7 +++++++
tests/line_piter.cc | 4 ++++
13 files changed, 90 insertions(+), 21 deletions(-)
Index: trunk/milena/tests/image_if_value.cc
===================================================================
--- trunk/milena/tests/image_if_value.cc (revision 1523)
+++ trunk/milena/tests/image_if_value.cc (revision 1524)
@@ -45,4 +45,11 @@
debug::iota(ima);
debug::println(ima);
debug::println(ima | 5);
+
+ I::fwd_piter p(ima.domain());
+ for_all(p)
+ {
+ mln_assertion((ima(p) == 5) ==
+ ((ima | 5).has(p)));
+ }
}
Index: trunk/milena/tests/image_if_interval.cc
===================================================================
--- trunk/milena/tests/image_if_interval.cc (revision 1523)
+++ trunk/milena/tests/image_if_interval.cc (revision 1524)
@@ -45,4 +45,11 @@
debug::iota(ima);
debug::println(ima);
debug::println(ima | value::interval(4, 7) );
+
+ I::fwd_piter p(ima.domain());
+ for_all(p)
+ {
+ mln_assertion((ima(p) >= 4 && ima(p) <= 7) ==
+ ((ima | value::interval(4, 7)).has(p)));
+ }
}
Index: trunk/milena/tests/line_piter.cc
===================================================================
--- trunk/milena/tests/line_piter.cc (revision 1523)
+++ trunk/milena/tests/line_piter.cc (revision 1524)
@@ -42,6 +42,10 @@
image2d<int> f(b, border);
image2d<int>::line_piter p(f.domain());
+ unsigned i = 1;
for_all(p)
+ {
+ mln_assertion(p[1] == 0 && p[0] == i++);
std::cout << p <<std::endl;
}
+}
Index: trunk/milena/mln/core/image_if.hh
===================================================================
--- trunk/milena/mln/core/image_if.hh (revision 1523)
+++ trunk/milena/mln/core/image_if.hh (revision 1524)
@@ -75,7 +75,7 @@
- /*! \brief An image class FIXME.
+ /*! \brief Image which domain is restricted by a function.
*
*/
template <typename I, typename F>
@@ -118,6 +118,9 @@
// Image | Function_p2b.
+ /// ima | f creates an image_if with the image ima and the function
+ /// f.
+ /// {{{
template <typename I, typename F>
image_if<I,F>
operator | (Image<I>& ima, const Function_p2b<F>& f);
@@ -125,6 +128,7 @@
template <typename I, typename F>
image_if<const I,F>
operator | (const Image<I>& ima, const Function_p2b<F>& f);
+ /// }}}
# ifndef MLN_INCLUDE_ONLY
Index: trunk/milena/mln/core/h_vec.hh
===================================================================
--- trunk/milena/mln/core/h_vec.hh (revision 1523)
+++ trunk/milena/mln/core/h_vec.hh (revision 1524)
@@ -34,7 +34,7 @@
*/
# include <mln/metal/vec.hh>
-
+# include <mln/literal/one.hh>
namespace mln
{
@@ -82,7 +82,9 @@
} // end of namespace mln::trait
-
+ /*! \brief N-Dimensional vector with homogeneous coordinates.
+ *
+ */
template <unsigned d, typename C>
struct h_vec : public metal::vec<d + 1, C>
{
@@ -91,8 +93,9 @@
/// Constructor without argument.
h_vec();
-
+ /// Constructor with the underlying vector.
h_vec(const metal::vec<d+1, C>& other);
+
h_vec& operator=(const metal::vec<d+1, C>& rhs);
/// Back to the natural (non-homogeneous) space.
@@ -133,7 +136,7 @@
h_vec<n, T> tmp;
for (unsigned i = 0; i < n; ++i)
tmp[i] = this->data_[i];
- tmp[n] = 1; // FIXME: literal::one
+ tmp[n] = literal::one;
return tmp;
}
Index: trunk/milena/mln/core/tr_image.hh
===================================================================
--- trunk/milena/mln/core/tr_image.hh (revision 1523)
+++ trunk/milena/mln/core/tr_image.hh (revision 1524)
@@ -61,7 +61,8 @@
} // end of namespace mln::internal
- /*! \brief FIXME
+ /*! \brief Morpher that makes an image become transformed by a given
+ * transformation.
*
*/
template <typename T, typename I>
Index: trunk/milena/mln/core/image_if_value.hh
===================================================================
--- trunk/milena/mln/core/image_if_value.hh (revision 1523)
+++ trunk/milena/mln/core/image_if_value.hh (revision 1524)
@@ -75,7 +75,7 @@
- /*! \brief An image class FIXME.
+ /*! \brief Image which domain is restricted by a single value.
*
*/
template <typename I>
@@ -124,6 +124,9 @@
// Image | value.
+ /// ima | v creates an image_if_value with the image ima and the
+ /// value v.
+ /// {{{
template <typename I>
image_if_value<I>
operator | (Image<I>& ima, const mln_value(I)& v);
@@ -131,7 +134,7 @@
template <typename I>
image_if_value<const I>
operator | (const Image<I>& ima, const mln_value(I)& v);
-
+ /// }}}
# ifndef MLN_INCLUDE_ONLY
Index: trunk/milena/mln/core/image_if_interval.hh
===================================================================
--- trunk/milena/mln/core/image_if_interval.hh (revision 1523)
+++ trunk/milena/mln/core/image_if_interval.hh (revision 1524)
@@ -83,7 +83,7 @@
- /*! \brief An image class FIXME.
+ /*! \brief Image which domain is restricted by an interval.
*
*/
template <typename I>
@@ -109,6 +109,9 @@
// Image | [from, to].
+ /// ima | vv creates an image_if_interval with the image ima and the
+ /// interval vv.
+ /// {{{
template <typename I>
image_if_interval<I>
operator | (Image<I>& ima, const value::interval_<mln_value(I)>& vv);
@@ -116,6 +119,7 @@
template <typename I>
image_if_interval<const I>
operator | (const Image<I>& ima, const value::interval_<mln_value(I)>& vv);
+ /// }}}
@@ -163,6 +167,7 @@
// Operators.
+
template <typename I>
image_if_interval<I>
operator | (Image<I>& ima, const value::interval_<mln_value(I)>& vv)
Index: trunk/milena/mln/core/h_mat.hh
===================================================================
--- trunk/milena/mln/core/h_mat.hh (revision 1523)
+++ trunk/milena/mln/core/h_mat.hh (revision 1524)
@@ -39,27 +39,35 @@
namespace mln
{
-
- template <unsigned dim, typename T>
- struct h_mat : public metal::mat<dim+1, dim+1, T>
+ /*! \brief N-Dimensional matrix with homogeneous coordinates.
+ *
+ */
+ template <unsigned d, typename T>
+ struct h_mat : public metal::mat<d+1, d+1, T>
{
- h_mat();
+ /// Dimension is the 'natural' one (3 for 3D), not the one of the vector (dim + 1)
+ enum { N = d,
+ M = d,
+ dim = d * d };
- h_mat(const metal::mat<dim+1, dim+1, T>& x);
+ /// Constructor without argument.
+ h_mat();
+ /// Constructor with the underlying matrix.
+ h_mat(const metal::mat<d+1, d+1, T>& x);
};
# ifndef MLN_INCLUDE_ONLY
- template <unsigned dim, typename T>
- h_mat<dim,T>::h_mat()
- : metal::mat<dim+1, dim+1, T>(metal::mat<dim+1, dim+1, T>::Id)
+ template <unsigned d, typename T>
+ h_mat<d,T>::h_mat()
+ : metal::mat<d+1, d+1, T>(metal::mat<d+1, d+1, T>::Id)
{
}
- template <unsigned dim, typename T>
- h_mat<dim,T>::h_mat(const metal::mat<dim+1, dim+1, T>& x)
- : metal::mat<dim+1, dim+1, T>(x)
+ template <unsigned d, typename T>
+ h_mat<d,T>::h_mat(const metal::mat<d+1, d+1, T>& x)
+ : metal::mat<d+1, d+1, T>(x)
{
}
Index: trunk/milena/mln/core/tr_mesh.hh
===================================================================
--- trunk/milena/mln/core/tr_mesh.hh (revision 1523)
+++ trunk/milena/mln/core/tr_mesh.hh (revision 1524)
@@ -47,6 +47,7 @@
{
typedef metal::false_ regular;
+ /// Constructor with the transformation.
tr_mesh(const T& tr)
: t_(tr)
{
Index: trunk/milena/mln/fun/x2x/composed.hh
===================================================================
--- trunk/milena/mln/fun/x2x/composed.hh (revision 1523)
+++ trunk/milena/mln/fun/x2x/composed.hh (revision 1524)
@@ -60,6 +60,7 @@
struct helper_composed_;
+ /// Helper for describing a bijective composition.
template <typename F, typename G, typename E>
struct helper_composed_< F, G, E, true>
: public fun::internal::x2x_linear_impl_<mln_result(F), E >,
@@ -69,16 +70,21 @@
using super_::dim;
+ /// Constructor without argument.
helper_composed_();
+ /// Constructor with the two transformation to be composed.
helper_composed_(const F& f, const G& g);
using super_::operator();
+ /// Set the new first transformation.
void set_first(const F& f);
+ /// Set the new second transformation.
void set_second(const G& g);
+ /// Type of the inverse function.
typedef composed<mln_invert(G),mln_invert(F)> invert;
-
+ /// Return the inverse function.
invert inv() const;
protected:
@@ -87,6 +93,7 @@
G g_;
};
+ /// Helper for describing a non bijective composition.
template <typename F, typename G, typename E>
struct helper_composed_< F, G, E, false>
: public fun::internal::x2x_linear_impl_<mln_result(F), E >,
@@ -96,12 +103,16 @@
using super_::dim;
+ /// Constructor without argument.
helper_composed_();
+ /// Constructor with the two transformation to be composed.
helper_composed_(const F& f, const G& g);
using super_::operator();
+ /// Set the new first transformation.
void set_first(const F& f);
+ /// Set the new second transformation.
void set_second(const G& g);
protected:
@@ -126,8 +137,10 @@
metal::is<mln_argument(F), mln_result(G)>
>::check_t
{
+ /// Constructor without argument.
composed() {}
+ /// Constructor with the two transformation to be composed.
composed(const F& f, const G& g)
: internal::helper_composed_<F, G, composed<F,G>,
mlc_is(F, Bijection_x2x<F>)::value &&
Index: trunk/milena/mln/fun/x2x/translation.hh
===================================================================
--- trunk/milena/mln/fun/x2x/translation.hh (revision 1523)
+++ trunk/milena/mln/fun/x2x/translation.hh (revision 1524)
@@ -60,15 +60,21 @@
{
typedef fun::internal::x2x_linear_impl_< metal::vec<n,C>, translation<n,C> > super_;
+ /// Type of the inverse function.
typedef translation<n,C> invert;
+ /// Return the inverse function.
invert inv() const;
+ /// Constructor without argument.
translation();
+ /// Constructor with the translation vector.
translation(const metal::vec<n,C>& t);
using super_::operator();
+ /// Perform the translation of the given vector
metal::vec<n,C> operator()(const metal::vec<n,C>& v) const;
+ /// Set a net translation vector.
void set_t(const metal::vec<n,C>& t);
protected:
Index: trunk/milena/mln/fun/x2x/rotation.hh
===================================================================
--- trunk/milena/mln/fun/x2x/rotation.hh (revision 1523)
+++ trunk/milena/mln/fun/x2x/rotation.hh (revision 1524)
@@ -58,16 +58,23 @@
{
typedef fun::internal::x2x_linear_impl_< metal::vec<n,C>, rotation<n,C> > super_;
+ /// Type of the inverse function.
typedef rotation<n,C> invert;
+ /// Return the invere function.
invert inv() const;
+ /// Constructor without argument.
rotation();
+ /// Constructor with grade alpha and a facultative direction (rotation axis).
rotation(float alpha, unsigned dir = 2);
using super_::operator();
+ /// Perform the rotation of the given vector.
metal::vec<n,C> operator()(const metal::vec<n,C>& v) const;
+ /// Set a new grade alpha.
void set_alpha(float alpha);
+ /// Set a new rotation axis.
void set_dir(unsigned dir);
protected:
1
0
Re: [Olena-patches] milena r1523: Subdirectory level ready for rereading (except median)
by Guillaume Duhamel 23 Nov '07
by Guillaume Duhamel 23 Nov '07
23 Nov '07
Guillaume Duhamel wrote:
> URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
>
> ChangeLog:
> 2007-11-23 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
>
> Subdirectory display ready for rereading (except median).
>
> Level review.
> * mln/level/abs.hh,
> * mln/level/all.hh,
> * mln/level/memcpy_.hh,
> * mln/level/memset_.hh,
> * mln/level/paste.hh,
> * mln/level/paste.spe.hh,
> * mln/level/saturate.hh,
> * mln/level/sort_points.hh,
> * mln/level/take.hh: Review doc, add precondition and check typo.
>
> Add metal::is_not_const.
> * mln/metal/is_not_const.hh: New file for handling check in
> memcpy and memset in level.
> * mln/metal/all.hh: Add is_not_const header.
>
> Add tests.
> * tests/all.cc: New tests, which include all headers all.hh.
>
> ---
> mln/level/abs.hh | 4 +
> mln/level/all.hh | 9 +++-
> mln/level/memcpy_.hh | 59 +++++++++++++++++++++++------
> mln/level/memset_.hh | 57 +++++++++++++++++++++-------
> mln/level/paste.hh | 3 -
> mln/level/paste.spe.hh | 2
> mln/level/saturate.hh | 14 ++++++
> mln/level/sort_points.hh | 12 +++++
> mln/level/take.hh | 2
> mln/metal/all.hh | 1
> mln/metal/is_not_const.hh | 68 +++++++++++++++++++++++++++++++++
> tests/all.cc | 93 ++++++++++++++++++++++++++++++++++++++++++++++
> 12 files changed, 292 insertions(+), 32 deletions(-)
>
> Index: trunk/milena/tests/all.cc
> ===================================================================
> --- trunk/milena/tests/all.cc (revision 0)
> +++ trunk/milena/tests/all.cc (revision 1523)
> @@ -0,0 +1,93 @@
> +// Copyright (C) 2007 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.
> +
> +/*! \file tests/all.cc
> + *
> + * \brief Tests with all headers. (check norris tests)
> + */
> +
> +
> +#include <mln/test/all.hh>
> +#include <mln/convert/all.hh>
> +#include <mln/estim/all.hh>
> +#include <mln/debug/all.hh>
> +#include <mln/histo/all.hh>
> +#include <mln/pw/all.hh>
> +#include <mln/geom/all.hh>
> +#include <mln/core/trait/all.hh>
> +#include <mln/fun/i2v/all.hh>
> +#include <mln/fun/p2b/all.hh>
> +#include <mln/fun/p2v/all.hh>
> +#include <mln/fun/v2v/all.hh>
> +#include <mln/fun/x2x/all.hh>
> +#include <mln/fun/all.hh>
> +#include <mln/math/all.hh>
> +#include <mln/set/all.hh>
> +#include <mln/draw/all.hh>
> +#include <mln/metal/math/all.hh>
> +#include <mln/metal/all.hh>
> +#include <mln/morpho/all.hh>
> +#include <mln/io/pfm/all.hh>
> +#include <mln/io/pgm/all.hh>
> +#include <mln/io/fits/all.hh>
> +#include <mln/io/ppm/all.hh>
> +#include <mln/io/pbm/all.hh>
> +#include <mln/io/pnm/all.hh>
> +#include <mln/io/all.hh>
> +#include <mln/level/naive/all.hh>
> +#include <mln/level/approx/all.hh>
> +#include <mln/level/all.hh>
> +#include <mln/arith/all.hh>
> +#include <mln/linear/all.hh>
> +#include <mln/logical/all.hh>
> +#include <mln/canvas/morpho/all.hh>
> +#include <mln/canvas/browsing/all.hh>
> +#include <mln/canvas/all.hh>
> +#include <mln/accu/all.hh>
> +#include <mln/norm/all.hh>
> +#include <mln/value/internal/all.hh>
> +#include <mln/value/all.hh>
> +#include <mln/value/concept/all.hh>
> +#include <mln/value/builtin/all.hh>
> +#include <mln/make/all.hh>
> +#include <mln/border/all.hh>
> +#include <mln/labeling/all.hh>
> +#include <mln/util/all.hh>
> +#include <mln/trait/all.hh>
> +#include <mln/trait/value/all.hh>
> +#include <mln/trait/op/all.hh>
> +#include <mln/tag/all.hh>
> +#include <mln/trace/all.hh>
> +#include <mln/literal/all.hh>
> +#include <mln/display/all.hh>
> +#include <mln/win/all.hh>
> +
> +
> +int main ()
> +{
> +
> +}
> Index: trunk/milena/mln/metal/is_not_const.hh
> ===================================================================
> --- trunk/milena/mln/metal/is_not_const.hh (revision 0)
> +++ trunk/milena/mln/metal/is_not_const.hh (revision 1523)
> @@ -0,0 +1,68 @@
> +// Copyright (C) 2007 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_METAL_IS_NOT_CONST_HH
> +# define MLN_METAL_IS_NOT_CONST_HH
> +
> +/*!
> + * \file mln/metal/is_not_const.hh
> + *
> + * \brief FIXME.
> + */
> +
> +# include <mln/metal/bool.hh>
> +
> +
> +# define mlc_is_not_const(T) mln::metal::is_not_const< T >
> +
> +
> +namespace mln
> +{
> +
> + namespace metal
> + {
> +
> + template <typename T>
> + struct is_not_const : true_
> + {};
> +
> + template <typename T>
> + struct is_not_const< const T > : false_
> + {};
> +
> + template <typename T>
> + struct is_not_const< const T& > : false_
> + {};
> +
> + // FIXME: What about "T*const" and "const T*"?
> +
> + } // end of namespace mln::metal
> +
> +} // end of namespace mln
> +
> +
> +#endif // ! MLN_METAL_IS_NOT_CONST_HH
> Index: trunk/milena/mln/metal/all.hh
> ===================================================================
> --- trunk/milena/mln/metal/all.hh (revision 1522)
> +++ trunk/milena/mln/metal/all.hh (revision 1523)
> @@ -63,6 +63,7 @@
> # include <mln/metal/const.hh>
> # include <mln/metal/unconst.hh>
> # include <mln/metal/is_const.hh>
> +# include <mln/metal/is_not_const.hh>
>
> # include <mln/metal/unptr.hh>
> # include <mln/metal/unref.hh>
> Index: trunk/milena/mln/level/sort_points.hh
> ===================================================================
> --- trunk/milena/mln/level/sort_points.hh (revision 1522)
> +++ trunk/milena/mln/level/sort_points.hh (revision 1523)
> @@ -49,7 +49,7 @@
> {
>
> /*! Sort points the image \p input through a function \p f to set
> - * the \p output image.
> + * the \p output image in increasing way.
> *
> * \param[in] input The input image.
> *
> @@ -58,6 +58,16 @@
> template <typename I>
> p_array<mln_point(I)> sort_points_increasing(const Image<I>& input);
>
> + /*! Sort points the image \p input through a function \p f to set
> + * the \p output image in decreasing way.
> + *
> + * \param[in] input The input image.
> + *
> + * \pre \p input.has_data
> + */
> + template <typename I>
> + p_array<mln_point(I)> sort_points_decreasing(const Image<I>& input);
> +
>
> # ifndef MLN_INCLUDE_ONLY
>
> Index: trunk/milena/mln/level/take.hh
> ===================================================================
> --- trunk/milena/mln/level/take.hh (revision 1522)
> +++ trunk/milena/mln/level/take.hh (revision 1523)
> @@ -53,6 +53,8 @@
> * This routine runs: \n
> * for all p of \p input, \p a.take( \p input(p) ) \n
> *
> + * \pre \p input has to be initialized.
> + *
> * \warning This routine does not perform a.init().
> */
> template <typename A, typename I>
> Index: trunk/milena/mln/level/saturate.hh
> ===================================================================
> --- trunk/milena/mln/level/saturate.hh (revision 1522)
> +++ trunk/milena/mln/level/saturate.hh (revision 1523)
> @@ -53,6 +53,9 @@
> * The saturation is based on the min and max values of the output
> * value type. This assumes that the range of values in the input
> * image is larger than the one of the output image.
> + *
> + * \pre \p input and \p output have to own the same domain.
> + *
> */
> template <typename I, typename O>
> void saturate(const Image<I>& input, Image<O>& output);
> @@ -64,6 +67,9 @@
> * \param[in] min The minimum output value.
> * \param[in] max The maximum output value.
> * \param[out] output The output image.
> + *
> + * \pre \p input and \p output have to own the same domain.
> + *
> */
> template <typename I, typename O>
> void saturate(const Image<I>& input,
> @@ -75,7 +81,10 @@
> *
> * \param[in,out] input The input image.
> * \param[in] min The minimum output value.
> - * \param[in] max The maximum output value.
> + * \param[in] max The maximum output value
> + *
> + * \pre \p input has to be initialized.
> + *
> */
> template <typename I>
> void saturate_inplace(Image<I>& input,
> @@ -90,6 +99,7 @@
> trace::entering("level::saturate");
>
> mln_precondition(exact(input).domain() == exact(output).domain());
> +
> fun::v2v::saturate<mln_value(O)> f;
> level::transform(input, f, output);
>
> @@ -104,6 +114,7 @@
> trace::entering("level::saturate");
>
> mln_precondition(exact(input).domain() == exact(output).domain());
> +
> fun::v2v::saturate<mln_value(O)> f(min, max);
> level::transform(input, f, output);
>
> @@ -117,6 +128,7 @@
> trace::entering("level::saturate_inplace");
>
> mln_precondition(exact(input).has_data());
> +
> fun::v2v::saturate<mln_value(I)> f(min, max);
> level::apply(input, f);
>
> Index: trunk/milena/mln/level/memcpy_.hh
> ===================================================================
> --- trunk/milena/mln/level/memcpy_.hh (revision 1522)
> +++ trunk/milena/mln/level/memcpy_.hh (revision 1523)
> @@ -37,7 +37,7 @@
>
> # include <mln/core/concept/image.hh>
> # include <mln/core/pixel.hh>
> -
> +# include <mln/metal/is_not_const.hh>
>
> namespace mln
> {
> @@ -52,7 +52,13 @@
> * \param[in] src The source pixel (to get values).
> * \param[in] n The number of pixels to copy.
> *
> - * \pre FIXME: !
> + * \pre \p src has to be initialized.
> + * \pre \p dest has to be initialized.
> + * \pre \p src and dest image values have to own the same sizeof.
> + * \pre \p dest pixel has to be on \p dest image domain.
> + * \pre \p src pixel has to be on \p src image domain.
> + * \pre \p dest + \p n has to be on \p dest image domain.
> + * \pre \p src + \p n has to be on \p src image domain.
> */
> template <typename Pd, typename Ps>
> void memcpy_(Generalized_Pixel<Pd>& dest, const Generalized_Pixel<Ps>& src,
> @@ -61,20 +67,16 @@
>
> # ifndef MLN_INCLUDE_ONLY
>
> + namespace impl
> + {
> +
> template <typename Pd, typename Ps>
> - void memcpy_(Generalized_Pixel<Pd>& dest_, const Generalized_Pixel<Ps>& src_,
> - std::size_t n)
> + void memcpy__(Pd& dest, const Ps& src, std::size_t n)
> {
> + trace::entering("level::impl::memcpy__");
> +
> typedef mln_image(Pd) Id;
> - // FIXME: metal::is_not_const<Id>::check();
> typedef mln_image(Ps) Is;
> - Pd& dest = internal::force_exact<Pd>(dest_);
> - Ps& src = internal::force_exact<Ps>(src_);
> -
> - mln_precondition(sizeof(mln_value(Id)) == sizeof(mln_value(Is)));
> - mln_precondition(dest.ima().has_data());
> - mln_precondition(src.ima().has_data());
> - // FIXME: Add precondition about n.
>
> if (n == 0)
> {
> @@ -100,6 +102,39 @@
> for (std::size_t i = 0; i < n; ++i)
> *p_d++ = *p_s++;
> }
> +
> + trace::exiting("level::impl::memcpy__");
> + }
> +
> + }
> +
> + template <typename Pd, typename Ps>
> + void memcpy_(Generalized_Pixel<Pd>& dest_, const Generalized_Pixel<Ps>& src_,
> + std::size_t n)
> + {
> + trace::entering("level::memcpy_");
> +
> + typedef mln_image(Pd) Id;
> + metal::is_not_const<Id>::check();
> + typedef mln_image(Ps) Is;
> + Pd& dest = internal::force_exact<Pd>(dest_);
> + Ps& src = internal::force_exact<Ps>(src_);
> +
> + mln_precondition(sizeof(mln_value(Id)) == sizeof(mln_value(Is)));
> + mln_precondition(dest.ima().has_data());
> + mln_precondition(src.ima().has_data());
> +
> + mln_precondition(& dest.val() >= & dest.ima()[0]);
> + mln_precondition(& dest.val() < & dest.ima()[0] + dest.ima().ncells());
> + mln_precondition(& dest.val() + n <= & dest.ima()[0] + dest.ima().ncells());
> +
> + mln_precondition(& src.val() >= & src.ima()[0]);
> + mln_precondition(& src.val() < & src.ima()[0] + src.ima().ncells());
> + mln_precondition(& src.val() + n <= & src.ima()[0] + src.ima().ncells());
> +
> + impl::memcpy__(dest, src, n);
> +
> + trace::exiting("level::memcpy_");
> }
>
> # endif // ! MLN_INCLUDE_ONLY
> Index: trunk/milena/mln/level/memset_.hh
> ===================================================================
> --- trunk/milena/mln/level/memset_.hh (revision 1522)
> +++ trunk/milena/mln/level/memset_.hh (revision 1523)
> @@ -35,7 +35,7 @@
>
> # include <mln/core/concept/image.hh>
> # include <mln/core/pixel.hh>
> -
> +# include <mln/metal/is_not_const.hh>
>
> namespace mln
> {
> @@ -49,7 +49,9 @@
> * \param[in] v The value to set pixels with.
> * \param[in] n The number of pixels to set.
> *
> - * \pre FIXME: !
> + * \pre \p pix image has to be initialized.
> + * \pre \p pix has to be on \p pix image domain.
> + * \pre \p pix + \p n has to be on \p pix image domain.
> */
> template <typename P>
> void memset_(Generalized_Pixel<P>& pix,
> @@ -63,7 +65,9 @@
> * \param[in] v The value to set to points.
> * \param[in] n The number of points to set.
> *
> - * \pre \p input has to be initialized. FIXME: More.
> + * \pre \p input image has to be initialized.
> + * \pre \p input has to own \p p.
> + * \pre \p p + \p n is <= \p input size.
> */
> template <typename I>
> void memset_(I& input, const mln_point(I)& p,
> @@ -72,19 +76,15 @@
>
> # ifndef MLN_INCLUDE_ONLY
>
> - template <typename P>
> - void memset_(Generalized_Pixel<P>& pix_,
> - const mln_value(P)& v, std::size_t n)
> + namespace impl
> {
> - typedef mln_image(P) I;
> - // FIXME: metal::is_not_const<I>::check();
>
> - P& pix = internal::force_exact<P>(pix_);
> - mln_precondition(pix.ima().has_data());
> - mln_precondition(& pix.val() >= & pix.ima()[0]);
> - mln_precondition(& pix.val() < & pix.ima()[0] + pix.ima().ncells());
> - mln_precondition(& pix.val() + n <= & pix.ima()[0] + pix.ima().ncells());
> + template <typename P>
> + void memset__(P& pix, const mln_value(P)& v, std::size_t n)
> + {
> + trace::entering("level::impl::memset_");
>
> + typedef mln_image(P) I;
> if (n == 0)
> {
> return; // no-op
> @@ -108,12 +108,39 @@
> for (std::size_t i = 0; i < n; ++i)
> *ptr++ = v;
> }
> +
> + trace::exiting("level::impl::memset_");
> + }
> +
> + } // end of namespace mln::level::impl
> +
> +
> + template <typename P>
> + void memset_(Generalized_Pixel<P>& pix_,
> + const mln_value(P)& v, std::size_t n)
> + {
> + trace::entering("level::memset_");
> +
> + typedef mln_image(P) I;
> + metal::is_not_const<I>::check();
> +
> + P& pix = internal::force_exact<P>(pix_);
> + mln_precondition(pix.ima().has_data());
> + mln_precondition(& pix.val() >= & pix.ima()[0]);
> + mln_precondition(& pix.val() < & pix.ima()[0] + pix.ima().ncells());
> + mln_precondition(& pix.val() + n <= & pix.ima()[0] + pix.ima().ncells());
> +
> + impl::memset__(pix, v, n);
> +
> + trace::exiting("level::memset_");
> }
>
> template <typename I>
> void memset_(I& input, const mln_point(I)& p,
> const mln_value(I)& v, std::size_t n)
> {
> + trace::entering("level::memset_");
> +
> mlc_is(mln_trait_image_speed(I), trait::image::speed::fastest)::check();
>
> mln_precondition(input.has_data());
> @@ -121,7 +148,9 @@
> mln_precondition(input.offset_at(p) + n <= input.ncells());
>
> pixel<I> pix(input, p);
> - memset_(pix, v, n);
> + impl::memset__(pix, v, n);
> +
> + trace::exiting("level::memset_");
> }
>
> # endif // ! MLN_INCLUDE_ONLY
> Index: trunk/milena/mln/level/paste.spe.hh
> ===================================================================
> --- trunk/milena/mln/level/paste.spe.hh (revision 1522)
> +++ trunk/milena/mln/level/paste.spe.hh (revision 1523)
> @@ -48,14 +48,12 @@
> namespace impl
> {
>
> -
> namespace generic
> {
> template <typename I, typename J>
> void paste_(const I& data, J& destination);
> }
>
> -
> template <typename I, typename J>
> void paste_lines_(const I& data, J& destination)
> {
> Index: trunk/milena/mln/level/abs.hh
> ===================================================================
> --- trunk/milena/mln/level/abs.hh (revision 1522)
> +++ trunk/milena/mln/level/abs.hh (revision 1523)
> @@ -69,8 +69,10 @@
> void abs(const Image<I>& input, Image<O>& output)
> {
> trace::entering("level::abs");
> +
> mln_precondition(exact(input).domain() == exact(output).domain());
> level::transform(input, fun::v2v::abs<mln_value(I)>(), output);
> +
> trace::exiting("level::abs");
> }
>
> @@ -78,8 +80,10 @@
> void abs_inplace(Image<I>& input)
> {
> trace::entering("level::abs_inplace");
> +
> mln_precondition(exact(input).has_data());
> level::apply(input, fun::v2v::abs<mln_value(I)>());
> +
> trace::exiting("level::abs_inplace");
> }
>
> Index: trunk/milena/mln/level/all.hh
> ===================================================================
> --- trunk/milena/mln/level/all.hh (revision 1522)
> +++ trunk/milena/mln/level/all.hh (revision 1523)
> @@ -40,8 +40,15 @@
> /// Namespace of image processing routines related to pixel levels.
> namespace level
> {
> +
> /// Implementation namespace of level namespace.
> - namespace impl {}
> + namespace impl {
> +
> + /// Generic implementation namespace of level namespace.
> + namespace generic {}
> +
> + }
> +
> }
>
> }
> Index: trunk/milena/mln/level/paste.hh
> ===================================================================
> --- trunk/milena/mln/level/paste.hh (revision 1522)
> +++ trunk/milena/mln/level/paste.hh (revision 1523)
> @@ -99,9 +99,10 @@
> template <typename I, typename J>
> void paste(const Image<I>& data_, Image<J>& destination_)
> {
> + trace::entering("level::paste");
> +
> const I& data = exact(data_);
> J& destination = exact(destination_);
> - trace::entering("level::paste");
>
> mlc_is(mln_trait_image_io(J), trait::image::io::write)::check();
> mlc_converts_to(mln_value(I), mln_value(J))::check();
>
Fix title.
1
0
milena r1523: Subdirectory display ready for rereading (except median)
by Guillaume Duhamel 23 Nov '07
by Guillaume Duhamel 23 Nov '07
23 Nov '07
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-23 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Subdirectory display ready for rereading (except median).
Level review.
* mln/level/abs.hh,
* mln/level/all.hh,
* mln/level/memcpy_.hh,
* mln/level/memset_.hh,
* mln/level/paste.hh,
* mln/level/paste.spe.hh,
* mln/level/saturate.hh,
* mln/level/sort_points.hh,
* mln/level/take.hh: Review doc, add precondition and check typo.
Add metal::is_not_const.
* mln/metal/is_not_const.hh: New file for handling check in
memcpy and memset in level.
* mln/metal/all.hh: Add is_not_const header.
Add tests.
* tests/all.cc: New tests, which include all headers all.hh.
---
mln/level/abs.hh | 4 +
mln/level/all.hh | 9 +++-
mln/level/memcpy_.hh | 59 +++++++++++++++++++++++------
mln/level/memset_.hh | 57 +++++++++++++++++++++-------
mln/level/paste.hh | 3 -
mln/level/paste.spe.hh | 2
mln/level/saturate.hh | 14 ++++++
mln/level/sort_points.hh | 12 +++++
mln/level/take.hh | 2
mln/metal/all.hh | 1
mln/metal/is_not_const.hh | 68 +++++++++++++++++++++++++++++++++
tests/all.cc | 93 ++++++++++++++++++++++++++++++++++++++++++++++
12 files changed, 292 insertions(+), 32 deletions(-)
Index: trunk/milena/tests/all.cc
===================================================================
--- trunk/milena/tests/all.cc (revision 0)
+++ trunk/milena/tests/all.cc (revision 1523)
@@ -0,0 +1,93 @@
+// Copyright (C) 2007 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.
+
+/*! \file tests/all.cc
+ *
+ * \brief Tests with all headers. (check norris tests)
+ */
+
+
+#include <mln/test/all.hh>
+#include <mln/convert/all.hh>
+#include <mln/estim/all.hh>
+#include <mln/debug/all.hh>
+#include <mln/histo/all.hh>
+#include <mln/pw/all.hh>
+#include <mln/geom/all.hh>
+#include <mln/core/trait/all.hh>
+#include <mln/fun/i2v/all.hh>
+#include <mln/fun/p2b/all.hh>
+#include <mln/fun/p2v/all.hh>
+#include <mln/fun/v2v/all.hh>
+#include <mln/fun/x2x/all.hh>
+#include <mln/fun/all.hh>
+#include <mln/math/all.hh>
+#include <mln/set/all.hh>
+#include <mln/draw/all.hh>
+#include <mln/metal/math/all.hh>
+#include <mln/metal/all.hh>
+#include <mln/morpho/all.hh>
+#include <mln/io/pfm/all.hh>
+#include <mln/io/pgm/all.hh>
+#include <mln/io/fits/all.hh>
+#include <mln/io/ppm/all.hh>
+#include <mln/io/pbm/all.hh>
+#include <mln/io/pnm/all.hh>
+#include <mln/io/all.hh>
+#include <mln/level/naive/all.hh>
+#include <mln/level/approx/all.hh>
+#include <mln/level/all.hh>
+#include <mln/arith/all.hh>
+#include <mln/linear/all.hh>
+#include <mln/logical/all.hh>
+#include <mln/canvas/morpho/all.hh>
+#include <mln/canvas/browsing/all.hh>
+#include <mln/canvas/all.hh>
+#include <mln/accu/all.hh>
+#include <mln/norm/all.hh>
+#include <mln/value/internal/all.hh>
+#include <mln/value/all.hh>
+#include <mln/value/concept/all.hh>
+#include <mln/value/builtin/all.hh>
+#include <mln/make/all.hh>
+#include <mln/border/all.hh>
+#include <mln/labeling/all.hh>
+#include <mln/util/all.hh>
+#include <mln/trait/all.hh>
+#include <mln/trait/value/all.hh>
+#include <mln/trait/op/all.hh>
+#include <mln/tag/all.hh>
+#include <mln/trace/all.hh>
+#include <mln/literal/all.hh>
+#include <mln/display/all.hh>
+#include <mln/win/all.hh>
+
+
+int main ()
+{
+
+}
Index: trunk/milena/mln/metal/is_not_const.hh
===================================================================
--- trunk/milena/mln/metal/is_not_const.hh (revision 0)
+++ trunk/milena/mln/metal/is_not_const.hh (revision 1523)
@@ -0,0 +1,68 @@
+// Copyright (C) 2007 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_METAL_IS_NOT_CONST_HH
+# define MLN_METAL_IS_NOT_CONST_HH
+
+/*!
+ * \file mln/metal/is_not_const.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/metal/bool.hh>
+
+
+# define mlc_is_not_const(T) mln::metal::is_not_const< T >
+
+
+namespace mln
+{
+
+ namespace metal
+ {
+
+ template <typename T>
+ struct is_not_const : true_
+ {};
+
+ template <typename T>
+ struct is_not_const< const T > : false_
+ {};
+
+ template <typename T>
+ struct is_not_const< const T& > : false_
+ {};
+
+ // FIXME: What about "T*const" and "const T*"?
+
+ } // end of namespace mln::metal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_METAL_IS_NOT_CONST_HH
Index: trunk/milena/mln/metal/all.hh
===================================================================
--- trunk/milena/mln/metal/all.hh (revision 1522)
+++ trunk/milena/mln/metal/all.hh (revision 1523)
@@ -63,6 +63,7 @@
# include <mln/metal/const.hh>
# include <mln/metal/unconst.hh>
# include <mln/metal/is_const.hh>
+# include <mln/metal/is_not_const.hh>
# include <mln/metal/unptr.hh>
# include <mln/metal/unref.hh>
Index: trunk/milena/mln/level/sort_points.hh
===================================================================
--- trunk/milena/mln/level/sort_points.hh (revision 1522)
+++ trunk/milena/mln/level/sort_points.hh (revision 1523)
@@ -49,7 +49,7 @@
{
/*! Sort points the image \p input through a function \p f to set
- * the \p output image.
+ * the \p output image in increasing way.
*
* \param[in] input The input image.
*
@@ -58,6 +58,16 @@
template <typename I>
p_array<mln_point(I)> sort_points_increasing(const Image<I>& input);
+ /*! Sort points the image \p input through a function \p f to set
+ * the \p output image in decreasing way.
+ *
+ * \param[in] input The input image.
+ *
+ * \pre \p input.has_data
+ */
+ template <typename I>
+ p_array<mln_point(I)> sort_points_decreasing(const Image<I>& input);
+
# ifndef MLN_INCLUDE_ONLY
Index: trunk/milena/mln/level/take.hh
===================================================================
--- trunk/milena/mln/level/take.hh (revision 1522)
+++ trunk/milena/mln/level/take.hh (revision 1523)
@@ -53,6 +53,8 @@
* This routine runs: \n
* for all p of \p input, \p a.take( \p input(p) ) \n
*
+ * \pre \p input has to be initialized.
+ *
* \warning This routine does not perform a.init().
*/
template <typename A, typename I>
Index: trunk/milena/mln/level/saturate.hh
===================================================================
--- trunk/milena/mln/level/saturate.hh (revision 1522)
+++ trunk/milena/mln/level/saturate.hh (revision 1523)
@@ -53,6 +53,9 @@
* The saturation is based on the min and max values of the output
* value type. This assumes that the range of values in the input
* image is larger than the one of the output image.
+ *
+ * \pre \p input and \p output have to own the same domain.
+ *
*/
template <typename I, typename O>
void saturate(const Image<I>& input, Image<O>& output);
@@ -64,6 +67,9 @@
* \param[in] min The minimum output value.
* \param[in] max The maximum output value.
* \param[out] output The output image.
+ *
+ * \pre \p input and \p output have to own the same domain.
+ *
*/
template <typename I, typename O>
void saturate(const Image<I>& input,
@@ -75,7 +81,10 @@
*
* \param[in,out] input The input image.
* \param[in] min The minimum output value.
- * \param[in] max The maximum output value.
+ * \param[in] max The maximum output value
+ *
+ * \pre \p input has to be initialized.
+ *
*/
template <typename I>
void saturate_inplace(Image<I>& input,
@@ -90,6 +99,7 @@
trace::entering("level::saturate");
mln_precondition(exact(input).domain() == exact(output).domain());
+
fun::v2v::saturate<mln_value(O)> f;
level::transform(input, f, output);
@@ -104,6 +114,7 @@
trace::entering("level::saturate");
mln_precondition(exact(input).domain() == exact(output).domain());
+
fun::v2v::saturate<mln_value(O)> f(min, max);
level::transform(input, f, output);
@@ -117,6 +128,7 @@
trace::entering("level::saturate_inplace");
mln_precondition(exact(input).has_data());
+
fun::v2v::saturate<mln_value(I)> f(min, max);
level::apply(input, f);
Index: trunk/milena/mln/level/memcpy_.hh
===================================================================
--- trunk/milena/mln/level/memcpy_.hh (revision 1522)
+++ trunk/milena/mln/level/memcpy_.hh (revision 1523)
@@ -37,7 +37,7 @@
# include <mln/core/concept/image.hh>
# include <mln/core/pixel.hh>
-
+# include <mln/metal/is_not_const.hh>
namespace mln
{
@@ -52,7 +52,13 @@
* \param[in] src The source pixel (to get values).
* \param[in] n The number of pixels to copy.
*
- * \pre FIXME: !
+ * \pre \p src has to be initialized.
+ * \pre \p dest has to be initialized.
+ * \pre \p src and dest image values have to own the same sizeof.
+ * \pre \p dest pixel has to be on \p dest image domain.
+ * \pre \p src pixel has to be on \p src image domain.
+ * \pre \p dest + \p n has to be on \p dest image domain.
+ * \pre \p src + \p n has to be on \p src image domain.
*/
template <typename Pd, typename Ps>
void memcpy_(Generalized_Pixel<Pd>& dest, const Generalized_Pixel<Ps>& src,
@@ -61,20 +67,16 @@
# ifndef MLN_INCLUDE_ONLY
+ namespace impl
+ {
+
template <typename Pd, typename Ps>
- void memcpy_(Generalized_Pixel<Pd>& dest_, const Generalized_Pixel<Ps>& src_,
- std::size_t n)
+ void memcpy__(Pd& dest, const Ps& src, std::size_t n)
{
+ trace::entering("level::impl::memcpy__");
+
typedef mln_image(Pd) Id;
- // FIXME: metal::is_not_const<Id>::check();
typedef mln_image(Ps) Is;
- Pd& dest = internal::force_exact<Pd>(dest_);
- Ps& src = internal::force_exact<Ps>(src_);
-
- mln_precondition(sizeof(mln_value(Id)) == sizeof(mln_value(Is)));
- mln_precondition(dest.ima().has_data());
- mln_precondition(src.ima().has_data());
- // FIXME: Add precondition about n.
if (n == 0)
{
@@ -100,6 +102,39 @@
for (std::size_t i = 0; i < n; ++i)
*p_d++ = *p_s++;
}
+
+ trace::exiting("level::impl::memcpy__");
+ }
+
+ }
+
+ template <typename Pd, typename Ps>
+ void memcpy_(Generalized_Pixel<Pd>& dest_, const Generalized_Pixel<Ps>& src_,
+ std::size_t n)
+ {
+ trace::entering("level::memcpy_");
+
+ typedef mln_image(Pd) Id;
+ metal::is_not_const<Id>::check();
+ typedef mln_image(Ps) Is;
+ Pd& dest = internal::force_exact<Pd>(dest_);
+ Ps& src = internal::force_exact<Ps>(src_);
+
+ mln_precondition(sizeof(mln_value(Id)) == sizeof(mln_value(Is)));
+ mln_precondition(dest.ima().has_data());
+ mln_precondition(src.ima().has_data());
+
+ mln_precondition(& dest.val() >= & dest.ima()[0]);
+ mln_precondition(& dest.val() < & dest.ima()[0] + dest.ima().ncells());
+ mln_precondition(& dest.val() + n <= & dest.ima()[0] + dest.ima().ncells());
+
+ mln_precondition(& src.val() >= & src.ima()[0]);
+ mln_precondition(& src.val() < & src.ima()[0] + src.ima().ncells());
+ mln_precondition(& src.val() + n <= & src.ima()[0] + src.ima().ncells());
+
+ impl::memcpy__(dest, src, n);
+
+ trace::exiting("level::memcpy_");
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/level/memset_.hh
===================================================================
--- trunk/milena/mln/level/memset_.hh (revision 1522)
+++ trunk/milena/mln/level/memset_.hh (revision 1523)
@@ -35,7 +35,7 @@
# include <mln/core/concept/image.hh>
# include <mln/core/pixel.hh>
-
+# include <mln/metal/is_not_const.hh>
namespace mln
{
@@ -49,7 +49,9 @@
* \param[in] v The value to set pixels with.
* \param[in] n The number of pixels to set.
*
- * \pre FIXME: !
+ * \pre \p pix image has to be initialized.
+ * \pre \p pix has to be on \p pix image domain.
+ * \pre \p pix + \p n has to be on \p pix image domain.
*/
template <typename P>
void memset_(Generalized_Pixel<P>& pix,
@@ -63,7 +65,9 @@
* \param[in] v The value to set to points.
* \param[in] n The number of points to set.
*
- * \pre \p input has to be initialized. FIXME: More.
+ * \pre \p input image has to be initialized.
+ * \pre \p input has to own \p p.
+ * \pre \p p + \p n is <= \p input size.
*/
template <typename I>
void memset_(I& input, const mln_point(I)& p,
@@ -72,19 +76,15 @@
# ifndef MLN_INCLUDE_ONLY
- template <typename P>
- void memset_(Generalized_Pixel<P>& pix_,
- const mln_value(P)& v, std::size_t n)
+ namespace impl
{
- typedef mln_image(P) I;
- // FIXME: metal::is_not_const<I>::check();
- P& pix = internal::force_exact<P>(pix_);
- mln_precondition(pix.ima().has_data());
- mln_precondition(& pix.val() >= & pix.ima()[0]);
- mln_precondition(& pix.val() < & pix.ima()[0] + pix.ima().ncells());
- mln_precondition(& pix.val() + n <= & pix.ima()[0] + pix.ima().ncells());
+ template <typename P>
+ void memset__(P& pix, const mln_value(P)& v, std::size_t n)
+ {
+ trace::entering("level::impl::memset_");
+ typedef mln_image(P) I;
if (n == 0)
{
return; // no-op
@@ -108,12 +108,39 @@
for (std::size_t i = 0; i < n; ++i)
*ptr++ = v;
}
+
+ trace::exiting("level::impl::memset_");
+ }
+
+ } // end of namespace mln::level::impl
+
+
+ template <typename P>
+ void memset_(Generalized_Pixel<P>& pix_,
+ const mln_value(P)& v, std::size_t n)
+ {
+ trace::entering("level::memset_");
+
+ typedef mln_image(P) I;
+ metal::is_not_const<I>::check();
+
+ P& pix = internal::force_exact<P>(pix_);
+ mln_precondition(pix.ima().has_data());
+ mln_precondition(& pix.val() >= & pix.ima()[0]);
+ mln_precondition(& pix.val() < & pix.ima()[0] + pix.ima().ncells());
+ mln_precondition(& pix.val() + n <= & pix.ima()[0] + pix.ima().ncells());
+
+ impl::memset__(pix, v, n);
+
+ trace::exiting("level::memset_");
}
template <typename I>
void memset_(I& input, const mln_point(I)& p,
const mln_value(I)& v, std::size_t n)
{
+ trace::entering("level::memset_");
+
mlc_is(mln_trait_image_speed(I), trait::image::speed::fastest)::check();
mln_precondition(input.has_data());
@@ -121,7 +148,9 @@
mln_precondition(input.offset_at(p) + n <= input.ncells());
pixel<I> pix(input, p);
- memset_(pix, v, n);
+ impl::memset__(pix, v, n);
+
+ trace::exiting("level::memset_");
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/level/paste.spe.hh
===================================================================
--- trunk/milena/mln/level/paste.spe.hh (revision 1522)
+++ trunk/milena/mln/level/paste.spe.hh (revision 1523)
@@ -48,14 +48,12 @@
namespace impl
{
-
namespace generic
{
template <typename I, typename J>
void paste_(const I& data, J& destination);
}
-
template <typename I, typename J>
void paste_lines_(const I& data, J& destination)
{
Index: trunk/milena/mln/level/abs.hh
===================================================================
--- trunk/milena/mln/level/abs.hh (revision 1522)
+++ trunk/milena/mln/level/abs.hh (revision 1523)
@@ -69,8 +69,10 @@
void abs(const Image<I>& input, Image<O>& output)
{
trace::entering("level::abs");
+
mln_precondition(exact(input).domain() == exact(output).domain());
level::transform(input, fun::v2v::abs<mln_value(I)>(), output);
+
trace::exiting("level::abs");
}
@@ -78,8 +80,10 @@
void abs_inplace(Image<I>& input)
{
trace::entering("level::abs_inplace");
+
mln_precondition(exact(input).has_data());
level::apply(input, fun::v2v::abs<mln_value(I)>());
+
trace::exiting("level::abs_inplace");
}
Index: trunk/milena/mln/level/all.hh
===================================================================
--- trunk/milena/mln/level/all.hh (revision 1522)
+++ trunk/milena/mln/level/all.hh (revision 1523)
@@ -40,8 +40,15 @@
/// Namespace of image processing routines related to pixel levels.
namespace level
{
+
/// Implementation namespace of level namespace.
- namespace impl {}
+ namespace impl {
+
+ /// Generic implementation namespace of level namespace.
+ namespace generic {}
+
+ }
+
}
}
Index: trunk/milena/mln/level/paste.hh
===================================================================
--- trunk/milena/mln/level/paste.hh (revision 1522)
+++ trunk/milena/mln/level/paste.hh (revision 1523)
@@ -99,9 +99,10 @@
template <typename I, typename J>
void paste(const Image<I>& data_, Image<J>& destination_)
{
+ trace::entering("level::paste");
+
const I& data = exact(data_);
J& destination = exact(destination_);
- trace::entering("level::paste");
mlc_is(mln_trait_image_io(J), trait::image::io::write)::check();
mlc_converts_to(mln_value(I), mln_value(J))::check();
1
0
23 Nov '07
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-23 Simon Nivault <simon.nivault(a)lrde.epita.fr>
Remove deprecated files and fix makefile.
* mln/fun/x2x/bijective_tr.hh: Remove, was in function concept.
* mln/fun/x2x/translation_alt.hh: Remove, was in translation.hh.
* tests/fun/x2x/Makefile.am: Fix.
---
trunk/milena/tests/fun/x2x/Makefile.am | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: trunk/milena/tests/fun/x2x/Makefile.am
===================================================================
--- trunk/milena/tests/fun/x2x/Makefile.am (revision 1521)
+++ trunk/milena/tests/fun/x2x/Makefile.am (revision 1522)
@@ -9,6 +9,6 @@
composed_SOURCES = composed.cc
rotation_SOURCES = rotation.cc
-translation_SOURCES = translation_SOURCES
+translation_SOURCES = translation.cc
TESTS = $(check_PROGRAMS)
Index: trunk/milena/mln/fun/x2x/bijective_tr.hh (deleted)
===================================================================
Index: trunk/milena/mln/fun/x2x/translation_alt.hh (deleted)
===================================================================
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-22 Simon Nivault <simon.nivault(a)lrde.epita.fr>
Review the directory fun and add test.
* mln/fun/x2x/bijective_tr.hh,
* mln/fun/x2x/composed.hh,
* mln/fun/x2x/rotation.hh,
* mln/fun/x2x/translation.hh: Review.
* tests/fun/Makefile.am: Add tests.
* tests/fun/x2x/Makefile.am: Add tests.
* tests/fun_x2x_composed.cc,
* tests/fun_x2x_rotation.cc,
* tests/fun_x2x_translation.cc: Rename as...
* tests/fun/x2x/composed.cc,
* tests/fun/x2x/rotation.cc,
* tests/fun/x2x/translation.cc... this.
* tests/set/Makefile.am: Fix.
---
mln/fun/x2x/bijective_tr.hh | 10 ++++-
mln/fun/x2x/composed.hh | 16 +++++++--
mln/fun/x2x/rotation.hh | 25 ++------------
mln/fun/x2x/translation.hh | 9 ++---
tests/fun/Makefile.am | 2 +
tests/fun/x2x/Makefile.am | 11 ++++++
tests/fun/x2x/composed.cc | 66 +++++++++++++++++++++++++++++++++++++++
tests/fun/x2x/rotation.cc | 72 +++++++++++++++++++++++++++++++++++++++++++
tests/fun/x2x/translation.cc | 59 +++++++++++++++++++++++++++++++++++
tests/set/Makefile.am | 2 -
10 files changed, 239 insertions(+), 33 deletions(-)
Index: trunk/milena/tests/fun_x2x_translation.cc (deleted)
===================================================================
Index: trunk/milena/tests/fun_x2x_rotation.cc (deleted)
===================================================================
Index: trunk/milena/tests/fun_x2x_composed.cc (deleted)
===================================================================
Index: trunk/milena/tests/fun/x2x/translation.cc
===================================================================
--- trunk/milena/tests/fun/x2x/translation.cc (revision 0)
+++ trunk/milena/tests/fun/x2x/translation.cc (revision 1521)
@@ -0,0 +1,59 @@
+// Copyright (C) 2007 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.
+
+/*! \file tests/fun_x2x_translation.cc
+ *
+ * \brief Tests on mln::fun::x2x::translation.
+ */
+
+#include <cmath>
+#include <iostream>
+#include <mln/fun/x2x/translation.hh>
+#include <mln/fun/i2v/all_to.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+
+ float
+ a = 2.3,
+ b = 0,
+ c = 2.9;
+
+ metal::vec<3,float> vec1 = make::vec(a, b, c);
+ fun::x2x::translation<3,float> tr1(all_to(1.6));
+
+ std::cout << vec1 << std::endl;
+ std::cout << tr1(vec1) << std::endl;
+ std::cout << tr1.inv()(vec1) << std::endl;
+ mln_assertion(tr1(tr1.inv()(vec1)) == vec1);
+ mln_assertion(fabs(tr1(vec1)[0] - 3.9) <= 0.125 &&
+ fabs(tr1(vec1)[1] - 1.6) <= 0.125 &&
+ fabs(tr1(vec1)[2] - 4.5) <= 0.125);
+}
Index: trunk/milena/tests/fun/x2x/rotation.cc
===================================================================
--- trunk/milena/tests/fun/x2x/rotation.cc (revision 0)
+++ trunk/milena/tests/fun/x2x/rotation.cc (revision 1521)
@@ -0,0 +1,72 @@
+// Copyright (C) 2007 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.
+
+/*! \file tests/fun_x2x_rotation.cc
+ *
+ * \brief Tests on mln::fun::x2x::rotation.
+ */
+
+
+#include <iostream>
+#include <mln/fun/x2x/rotation.hh>
+#include <mln/core/image2d.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/core/interpolated.hh>
+#include <mln/make/vec.hh>
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ image2d<int_u8> lena = io::pgm::load("../../../img/lena.pgm");
+ image2d<int_u8> out(lena.domain());
+
+ interpolated<image2d<int_u8> > inter(lena);
+
+ fun::x2x::rotation<2,float> rot1(0.1);
+
+ image2d<int_u8>::fwd_piter p(out.domain());
+
+ for_all(p)
+ {
+ metal::vec<2,float> v = rot1.inv()((point2d::vec_t)(point2d)p);
+ if (inter.owns_(v))
+ out(p) = inter(v);
+ else
+ out(p) = 255;
+ }
+ io::pgm::save(out, "out.pgm");
+
+ fun::x2x::rotation<2,float> rot2(3.14116);
+ mln_assertion(fabs(rot2(make::vec(0.0, 1.0))[0] -
+ make::vec(0.0, -1.0)[0]) <= 0.125);
+ mln_assertion(fabs(rot2(make::vec(0.0, 1.0))[1] -
+ make::vec(0.0, -1.0)[1]) <= 0.125);
+}
Index: trunk/milena/tests/fun/x2x/Makefile.am
===================================================================
--- trunk/milena/tests/fun/x2x/Makefile.am (revision 1520)
+++ trunk/milena/tests/fun/x2x/Makefile.am (revision 1521)
@@ -1,3 +1,14 @@
## Process this file through Automake to create Makefile.in -*- Makefile -*-
include $(top_srcdir)/milena/tests/tests.mk
+
+check_PROGRAMS = \
+ composed \
+ rotation \
+ translation
+
+composed_SOURCES = composed.cc
+rotation_SOURCES = rotation.cc
+translation_SOURCES = translation_SOURCES
+
+TESTS = $(check_PROGRAMS)
Index: trunk/milena/tests/fun/x2x/composed.cc
===================================================================
--- trunk/milena/tests/fun/x2x/composed.cc (revision 0)
+++ trunk/milena/tests/fun/x2x/composed.cc (revision 1521)
@@ -0,0 +1,66 @@
+// Copyright (C) 2007 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.
+
+/*! \file tests/fun_x2x_composed.cc
+ *
+ * \brief Tests on mln::fun::x2x::composed.
+ */
+
+
+#include <iostream>
+#include <mln/fun/x2x/translation.hh>
+#include <mln/fun/x2x/rotation.hh>
+#include <mln/fun/x2x/composed.hh>
+#include <mln/fun/i2v/all_to.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+
+ float
+ a = 2.3,
+ b = 0,
+ c = 2.9;
+
+ metal::vec<3,float> vec1 = make::vec(a, b, c);
+ fun::x2x::translation<3,float> tr(all_to(1.6));
+ fun::x2x::rotation<3,float> rot(0.3, 1);
+
+ std::cout << "vec : " << vec1 << std::endl;
+ std::cout << "tr(vec) : " << tr(vec1) << std::endl;
+ std::cout << "rot(vec) : " << rot(vec1) << std::endl;
+ std::cout << "tr(rot(vec)) : " << compose(tr, rot)(vec1) << std::endl;
+ std::cout << "rot(rot_1(vec)) : " << compose(rot, rot.inv())(vec1) << std::endl;
+ std::cout << "tr(rot(tr(vec))) : " << compose(tr, compose(rot, tr))(vec1) << std::endl;
+ std::cout << "(rototr_1)(rot(tr(vec)))) : "
+ << compose(compose(rot, tr).inv(), compose(rot, tr))(vec1) << std::endl;
+ mln_assertion(fabs(compose(rot, tr)(vec1)[0] - rot(tr(vec1))[0]) <= 0.125);
+ mln_assertion(fabs(compose(rot, tr)(vec1)[1] - rot(tr(vec1))[1]) <= 0.125);
+ mln_assertion(fabs(compose(rot, tr)(vec1)[2] - rot(tr(vec1))[2]) <= 0.125);
+}
Index: trunk/milena/tests/fun/Makefile.am
===================================================================
--- trunk/milena/tests/fun/Makefile.am (revision 1520)
+++ trunk/milena/tests/fun/Makefile.am (revision 1521)
@@ -1,3 +1,5 @@
## Process this file through Automake to create Makefile.in -*- Makefile -*-
include $(top_srcdir)/milena/tests/tests.mk
+
+SUBDIRS = x2x
Index: trunk/milena/tests/set/Makefile.am
===================================================================
--- trunk/milena/tests/set/Makefile.am (revision 1520)
+++ trunk/milena/tests/set/Makefile.am (revision 1521)
@@ -11,7 +11,7 @@
diff_SOURCES = diff.cc
inter_SOURCES = inter.cc
-is_subset_SOURCES = is_subset.cc
+is_subset_of_SOURCES = is_subset.cc
sym_diff_SOURCES = sym_diff.cc
uni_SOURCES = uni.cc
Index: trunk/milena/mln/fun/x2x/composed.hh
===================================================================
--- trunk/milena/mln/fun/x2x/composed.hh (revision 1520)
+++ trunk/milena/mln/fun/x2x/composed.hh (revision 1521)
@@ -30,7 +30,7 @@
/*! \file mln/fun/x2x/composed.hh
*
- * \brief FIXME.
+ * \brief Definition of a composed transformation.
*/
# include <mln/core/concept/function.hh>
@@ -112,8 +112,9 @@
} // end of namespace mln::fun::x2x::internal
- // FIXME: Doc!
-
+ /*! \brief Represent a composition of two transformations.
+ *
+ */
template <typename F, typename G>
struct composed
: public internal::helper_composed_<F, G, composed<F,G>,
@@ -139,6 +140,13 @@
} // end of namespace mln::fun
+ /*! \brief Do a composition of two transformations
+ *
+ * \param[in] f The first transformation.
+ * \param[in] g The second transformation.
+ *
+ * \return The composed transformation fog.
+ */
template <typename F, typename G>
fun::x2x::composed<F,G> compose(F f, G g);
@@ -232,7 +240,9 @@
template <typename F, typename G>
fun::x2x::composed<F,G> compose(F f, G g)
{
+ trace::entering("fun::x2x::compose");
fun::x2x::composed<F,G> comp(f, g);
+ trace::exiting("fun::x2x::compose");
return comp;
}
Index: trunk/milena/mln/fun/x2x/bijective_tr.hh
===================================================================
--- trunk/milena/mln/fun/x2x/bijective_tr.hh (revision 1520)
+++ trunk/milena/mln/fun/x2x/bijective_tr.hh (revision 1521)
@@ -30,7 +30,7 @@
/*! \file mln/fun/x2x/bijective_tr.hh
*
- * \brief FIXME.
+ * \brief Abstraction that describes a bijective transformation.
*/
# include <mln/core/concept/function.hh>
@@ -47,8 +47,12 @@
namespace x2x
{
- // FIXME: Doc!
-
+ /*! \brief Abstraction that describes a bijective transformation.
+ *
+ * All bijective transformation from vector to vector should
+ * should inherit this class.
+ *
+ */
template <typename E>
struct bijective_tr : public Function_x2x< E >
{
Index: trunk/milena/mln/fun/x2x/translation.hh
===================================================================
--- trunk/milena/mln/fun/x2x/translation.hh (revision 1520)
+++ trunk/milena/mln/fun/x2x/translation.hh (revision 1521)
@@ -30,7 +30,7 @@
/*! \file mln/fun/x2x/translation.hh
*
- * \brief FIXME.
+ * \brief Define a translation function.
*/
# include <mln/core/concept/function.hh>
@@ -48,8 +48,9 @@
namespace x2x
{
- // FIXME: Doc!
-
+ /*! \brief Represent a translation function.
+ *
+ */
template <unsigned n, typename C>
struct translation
@@ -82,8 +83,6 @@
template <unsigned n, typename C>
translation<n,C>::translation()
{
-// t_ = make::vec<n,C>(fun::i2v::all<C>(0));
-// this->m_ = h_mat<n,C>::Id;
}
template <unsigned n, typename C>
Index: trunk/milena/mln/fun/x2x/rotation.hh
===================================================================
--- trunk/milena/mln/fun/x2x/rotation.hh (revision 1520)
+++ trunk/milena/mln/fun/x2x/rotation.hh (revision 1521)
@@ -30,7 +30,7 @@
/*! \file mln/fun/x2x/rotation.hh
*
- * \brief FIXME.
+ * \brief Define a rotation function.
*/
# include <mln/core/concept/function.hh>
@@ -48,8 +48,9 @@
namespace x2x
{
- // FIXME: Doc!
-
+ /*! \brief Represent a rotation function.
+ *
+ */
template <unsigned n, typename C>
struct rotation
: internal::x2x_linear_impl_< metal::vec<n,C>, rotation<n,C> >
@@ -82,9 +83,6 @@
template <unsigned n, typename C>
rotation<n,C>::rotation()
{
-// alpha_ = 0;
-// dir_ = 2;
-// this->m_ = h_mat<n,C>::Id;
}
template <unsigned n, typename C>
@@ -159,21 +157,6 @@
}
}
-// template <typename C> FIXME : template parameter should be swapped
-// void
-// rotation<2,C>::update()
-// {
-// const float cos_a = cos(alpha_);
-// const float sin_a = sin(alpha_);
-
-// m_ = metal::mat<3,3,C>::Id;
-// m_(0, 0) = cos_a;
-// m_(0, 1) = -sin_a;
-// m_(1, 0) = sin_a;
-// m_(1, 1) = cos_a;
-// }
-
-
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::fun::x2x
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-22 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Subdirectory display ready for rereading.
* mln/display/all.hh,
* mln/display/color_pretty.hh,
* mln/display/remove.hh: Fix type and tracing.
Tests
* tests/display/save_and_show.cc,
* tests/display/show.cc: Update tests.
---
mln/display/all.hh | 8 +++++++-
mln/display/color_pretty.hh | 4 ++++
mln/display/remove.hh | 3 +--
tests/display/save_and_show.cc | 11 +++++++----
tests/display/show.cc | 15 +++++++++------
5 files changed, 28 insertions(+), 13 deletions(-)
Index: trunk/milena/tests/display/show.cc
===================================================================
--- trunk/milena/tests/display/show.cc (revision 1519)
+++ trunk/milena/tests/display/show.cc (revision 1520)
@@ -72,12 +72,15 @@
display::show (t, "display", 1);
}
-// image2d<value::rgb8> color_image (16, 16);
-// for (int i = 0; i < 16; ++i)
-// for (int j = 0; j < 16; ++j)
-// color_image(point2d(i, j)) = value::rgb8(0,0,255);
-// display::save (color_image);
-// display::show (color_image, "display");
+ /// Test with color image.
+ {
+ image2d<value::rgb8> color_image (16, 16);
+ for (int i = 0; i < 16; ++i)
+ for (int j = 0; j < 16; ++j)
+ color_image(point2d(i, j)) = value::rgb8(0,0,255);
+ display::save (color_image);
+ display::show (color_image, "display", 1);
+ }
display::remove ();
}
Index: trunk/milena/tests/display/save_and_show.cc
===================================================================
--- trunk/milena/tests/display/save_and_show.cc (revision 1519)
+++ trunk/milena/tests/display/save_and_show.cc (revision 1520)
@@ -68,8 +68,11 @@
display::save_and_show (t, "display", 1);
}
- /// FIXME: Uncomment this ASAP
-// image2d<value::rgb8> ima (100, 100);
-// level::fill(ima, value::rgb8 (0, 0, 255));
-// display::save_and_show (ima, "display", 1);
+ /// Test with color image.
+ {
+ image2d<value::rgb8> ima (100, 100);
+ level::fill(ima, value::rgb8 (0, 0, 255));
+ display::save_and_show (ima, "display", 1);
+ }
+
}
Index: trunk/milena/mln/display/color_pretty.hh
===================================================================
--- trunk/milena/mln/display/color_pretty.hh (revision 1519)
+++ trunk/milena/mln/display/color_pretty.hh (revision 1520)
@@ -141,6 +141,8 @@
const p_set<mln_point(I) >& s2_,
const p_set<mln_point(I) >& s3_)
{
+ trace::entering("display::impl::color_pretty_rgb");
+
const I& input = exact (input_);
image2d<value::rgb8> output(input.domain().bbox());
@@ -166,6 +168,8 @@
for_all(p)
output(p).blue() = 255;
}
+
+ trace::exiting("display::impl::color_pretty_rgb");
return output;
}
Index: trunk/milena/mln/display/all.hh
===================================================================
--- trunk/milena/mln/display/all.hh (revision 1519)
+++ trunk/milena/mln/display/all.hh (revision 1520)
@@ -41,7 +41,13 @@
namespace display
{
/// Implementation namespace of display namespace.
- namespace impl {}
+ namespace impl {
+
+ /// Generic implementation namespace of display namespace.
+ namespace generic {}
+
+ }
+
}
}
Index: trunk/milena/mln/display/remove.hh
===================================================================
--- trunk/milena/mln/display/remove.hh (revision 1519)
+++ trunk/milena/mln/display/remove.hh (revision 1520)
@@ -51,8 +51,7 @@
* save.
*
*/
- void
- remove();
+ void remove();
# ifndef MLN_INCLUDE_ONLY
1
0