https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Alexandre Abraham <abraham(a)lrde.epita.fr>
Fix for two ways functions.
* mln/value/shell.hh: Little fix for v2w_w2v functions.
shell.hh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Index: mln/value/shell.hh
--- mln/value/shell.hh (revision 3154)
+++ mln/value/shell.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008, 2009 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
@@ -162,7 +162,7 @@
template <typename F, typename I>
mln_value(I) shell_<F, I, Function_v2w_w2v<void> >::set_ (I &ima, const mln_site(I) &s, const typename F::result &v)
{
- ima(s) = F().f_1(ima(s), v);
+ ima(s) = F().f_1(v, ima(s));
return ima(s);
}
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
Index: ChangeLog
from Alexandre Abraham <abraham(a)lrde.epita.fr>
Move some files to trunk.
* abraham/mln/morpho/autarkical_leveling.hh: Update.
* abraham/mln/morpho/vmt.hh: New
For test purpose.
* abraham/mln/morpho/vector_median.hh: Update.
* abraham/mln/core/concept/meta_fun.hh: Move to trunk.
* abraham/mln/math/cos.hh: Move to trunk.
* abraham/mln/math/acos.hh: Move to trunk.
* abraham/mln/value/shell.hh: Move to trunk.
core/concept/meta_fun.hh | 79 -----------------
math/acos.hh | 65 --------------
math/cos.hh | 65 --------------
morpho/autarkical_leveling.hh | 67 ++++++++------
morpho/vector_median.hh | 2
morpho/vmt.hh | 126 +++++++++++++++++++++++++++
value/shell.hh | 190 ------------------------------------------
7 files changed, 166 insertions(+), 428 deletions(-)
Index: abraham/mln/morpho/autarkical_leveling.hh
--- abraham/mln/morpho/autarkical_leveling.hh (revision 3055)
+++ abraham/mln/morpho/autarkical_leveling.hh (working copy)
@@ -37,11 +37,8 @@
# include <mln/morpho/includes.hh>
# include <mln/morpho/general.hh>
-# include <mln/accu/land.hh>
-# include <mln/accu/land_basic.hh>
-# include <mln/accu/min.hh>
-# include <mln/accu/min_h.hh>
# include <mln/norm/l2.hh>
+# include <mln/level/paste.hh>
namespace mln
{
@@ -74,23 +71,27 @@
const W& win = exact(win_);
O output;
+ O ref;
output = clone(input);
-
- bool modification = true;
+ ref = clone(input);
mln_piter(I) p(input.domain());
mln_qiter(W) q(win, p);
mln_qiter(W) r(win, p);
+ bool stable = false;
+ while (!stable)
+ {
+ stable = true;
for_all(p)
{
mln_psite(W) v;
double min_dist = std::numeric_limits<double>::infinity();
bool same_side = true;
- for_all(q) if (input.domain().has(q))
+ for_all(q) if (ref.domain().has(q))
{
- for_all(r) if (input.domain().has(r) && q!=r)
- if ((marker(q) - input(p)) * (marker(r) - input(p)) < 0)
+ for_all(r) if (ref.domain().has(r) && q!=r)
+ if ((marker(q) - ref(p)) * (marker(r) - ref(p)) < 0)
{
same_side = false;
break;
@@ -99,7 +100,7 @@
if (!same_side)
break;
- double dist = norm::l2(input(p) - marker(q));
+ double dist = norm::l2(ref(p) - marker(q));
if (dist < min_dist)
{
min_dist = dist;
@@ -107,9 +108,19 @@
}
}
if (same_side)
+ {
+ if (output(p) != marker(v))
+ stable = false;
output(p) = marker(v);
+ }
else
- output(p) = input(p);
+ {
+ if (output(p) != ref(p))
+ stable = false;
+ output(p) = ref(p);
+ }
+ }
+ level::paste(output, ref);
}
trace::exiting("morpho::impl::general_on_set_centered__autarkical_leveling");
Index: abraham/mln/morpho/vmt.hh
--- abraham/mln/morpho/vmt.hh (revision 0)
+++ abraham/mln/morpho/vmt.hh (revision 0)
@@ -0,0 +1,126 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_MORPHO_VMT_HH
+# define MLN_MORPHO_VMT_HH
+
+/// \file mln/morpho/vector_median.hh
+///
+/// Morphological vector median filter.
+///
+/// \todo The overloads are hidden and I don't know why!
+
+# include <mln/morpho/includes.hh>
+# include <mln/morpho/general.hh>
+# include <mln/accu/land.hh>
+# include <mln/accu/land_basic.hh>
+# include <mln/accu/min.hh>
+# include <mln/accu/min_h.hh>
+# include <mln/norm/l2.hh>
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ /// Morphological vector_median.
+ template <typename I, typename W>
+ mln_concrete(I)
+ vmt(const Image<I>& input, const Window<W>& win);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ // On set with centered window (overloads).
+
+ template <typename I, typename W>
+ mln_concrete(I)
+ vmt(const Image<I>& input_, const Window<W>& win_)
+ {
+ trace::entering("morpho::impl::general_on_set_centered__vector_median");
+
+ typedef mln_concrete(I) O;
+ const I& input = exact(input_);
+ const W& win = exact(win_);
+
+ O output;
+ output = clone(input);
+
+ mln_piter(I) p(input.domain());
+ mln_qiter(W) q(win, p);
+ for_all(p)
+ {
+ mln_psite(W) v;
+ double min_dist = std::numeric_limits<double>::infinity();
+ for_all(q) if (input.domain().has(q))
+ {
+ double dist = norm::l2(input(p) - input(q));
+ if (dist < min_dist)
+ {
+ min_dist = dist;
+ v = q;
+ }
+ }
+ output(p) = input(v);
+ }
+
+ trace::exiting("morpho::impl::general_on_set_centered__vector_median");
+ return output;
+ }
+
+
+ } // end of namespace morpho::impl
+
+
+ template <typename I, typename W>
+ inline
+ mln_concrete(I)
+ vmt(const Image<I>& input, const Window<W>& win)
+ {
+ trace::entering("morpho::vector_median");
+ mln_precondition(exact(input).has_data());
+ mln_precondition(! exact(win).is_empty());
+
+ mln_concrete(I) output = impl::vector_median(input, win);
+
+ trace::exiting("morpho::vector_median");
+ return output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_VMT_HH
Index: abraham/mln/morpho/vector_median.hh
--- abraham/mln/morpho/vector_median.hh (revision 3055)
+++ abraham/mln/morpho/vector_median.hh (working copy)
@@ -84,7 +84,7 @@
double min_dist = std::numeric_limits<double>::infinity();
for_all(q) if (input.domain().has(q))
{
- double dist = 0;
+ double dist = norm::l2(input(p) - input(q));
for_all(r) if (input.domain().has(r) && q!=r)
dist += norm::l2(input(r) - input(q));
if (dist < min_dist)
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Nicolas Ballas <ballas(a)lrde.epita.fr>
Add opt::value routine.
* mln/core/image/flat_image.hh: Update specific method ands typedefs.
* mln/core/concept/image.hh: Remove check of a deprecated spe method.
* mln/opt/at.hh: Add documentation.
* mln/opt/value.hh: New, opt::value routine.
* mln/value/sign.hh: Update documentation.
* tests/core/image/flat_image.cc: Update tests.
* tests/opt/value.cc: New tests.
mln/core/concept/image.hh | 3
mln/core/image/flat_image.hh | 30 ++-------
mln/opt/at.hh | 18 ++++-
mln/opt/value.hh | 124 +++++++++++++++++++++++++++++++++++++++++
mln/value/sign.hh | 2
tests/core/image/flat_image.cc | 2
tests/opt/value.cc | 52 +++++++++++++++++
7 files changed, 201 insertions(+), 30 deletions(-)
Index: mln/core/image/flat_image.hh
--- mln/core/image/flat_image.hh (revision 3149)
+++ mln/core/image/flat_image.hh (working copy)
@@ -117,7 +117,7 @@
typedef const T& rvalue;
/// Return type of read-write access.
- typedef const T& lvalue;
+ typedef T& lvalue;
/// Constructor without argument.
@@ -140,13 +140,12 @@
const T& operator()(const mln_psite(S)& p) const;
/// Read-write access to the image value located at point \p p.
- const T& operator()(const mln_psite(S)& p);
+ T& operator()(const mln_psite(S)& p);
- /// Change the image value.
- void change_value(const T& old_val, const T& new_val);
- const T& val() const;
- T& val();
+ /// Specific methods.
+ const T& value_() const;
+ T& value_();
};
@@ -238,7 +237,7 @@
template <typename T, typename S>
inline
- const T&
+ T&
flat_image<T,S>::operator()(const mln_psite(S)&)
{
mln_precondition(this->is_valid());
@@ -247,21 +246,8 @@
template <typename T, typename S>
inline
- void
- flat_image<T,S>::change_value(const T& old_val, const T& new_val)
- {
- mln_precondition(this->is_valid());
- mln_precondition(old_val == this->data_->val_);
- this->data_->val_ = new_val;
-
- /// Avoid warning when NDEBUG is set
- (void) old_val;
- }
-
- template <typename T, typename S>
- inline
const T&
- flat_image<T,S>::val() const
+ flat_image<T,S>::value_() const
{
mln_precondition(this->is_valid());
return this->data_->val_;
@@ -270,7 +256,7 @@
template <typename T, typename S>
inline
T&
- flat_image<T,S>::val()
+ flat_image<T,S>::value_()
{
mln_precondition(this->is_valid());
return this->data_->val_;
Index: mln/core/concept/image.hh
--- mln/core/concept/image.hh (revision 3149)
+++ mln/core/concept/image.hh (working copy)
@@ -148,9 +148,6 @@
{
static void run()
{
- void (E::*m)(const typename E::value& old_val,
- const typename E::value& new_val) = & E::change_value;
- m = 0;
}
};
Index: mln/opt/at.hh
--- mln/opt/at.hh (revision 3149)
+++ mln/opt/at.hh (working copy)
@@ -31,7 +31,7 @@
/// \file mln/opt/at.hh
///
-/// FIXME
+/// Define the optional routine at.
# include <mln/core/concept/image.hh>
# include <mln/trait/images.hh>
@@ -48,26 +48,38 @@
{
/// One dimension
+ /// Read-only access to the \p ima value located at (\p ind).
template <typename I>
mln_rvalue(I) at(const Image<I>& ima, def::coord ind);
+ /// Read-write access to the \p ima value located at (\p ind).
template <typename I>
mln_lvalue(I) at(Image<I>& ima, def::coord ind);
/// Two dimensions
+ /// Read-only access to the \p ima value located at (\p row, \p col).
template <typename I>
mln_rvalue(I) at(const Image<I>& ima, def::coord row, def::coord col);
+ /// Read-write access to the \p ima value located at (\p row, \p col).
template <typename I>
mln_lvalue(I) at(Image<I>& ima, def::coord row, def::coord col);
/// Three dimensions
+ /// Read-only access to the \p ima value located at
+ /// (\p sli, \p row, \p col).
template <typename I>
- mln_rvalue(I) at(const Image<I>& ima, def::coord sli, def::coord row, def::coord col);
+ mln_rvalue(I) at(const Image<I>& ima,
+ def::coord sli, def::coord row, def::coord col);
+
+
+ /// Read-write access to the \p ima value located at
+ /// (\p sli, \p row, \p col).
template <typename I>
- mln_lvalue(I) at(Image<I>& ima, def::coord sli, def::coord row, def::coord col);
+ mln_lvalue(I) at(Image<I>& ima,
+ def::coord sli, def::coord row, def::coord col);
# ifndef MLN_INCLUDE_ONLY
Index: mln/opt/value.hh
--- mln/opt/value.hh (revision 0)
+++ mln/opt/value.hh (revision 0)
@@ -0,0 +1,124 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+// (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_OPT_VALUE_HH
+# define MLN_OPT_VALUE_HH
+
+/// \file mln/opt/value.hh
+///
+/// Define the opt::value routine.
+
+# include <mln/core/concept/image.hh>
+# include <mln/trait/images.hh>
+
+namespace mln
+{
+
+ namespace opt
+ {
+
+ template <typename I>
+ inline
+ mln_rvalue(I) value(const Image<I>& ima);
+
+ template <typename I>
+ inline
+ mln_lvalue(I) value(Image<I>& ima);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ template <typename I>
+ inline
+ mln_rvalue(I) value_impl(trait::image::category::domain_morpher,
+ const Image<I>& ima)
+ {
+ return value(*exact(ima).delegatee_());
+ }
+
+ template <typename I>
+ inline
+ mln_rvalue(I) value_impl(trait::image::category::any,
+ const Image<I>& ima)
+ {
+ mlc_is(mln_trait_image_value_storage(I),
+ trait::image::value_storage::singleton)::check();
+ return exact(ima).value_();
+ }
+
+
+
+
+ template <typename I>
+ inline
+ mln_lvalue(I) value_impl(trait::image::category::domain_morpher,
+ Image<I>& ima)
+ {
+ return value(*exact(ima).delegatee_());
+ }
+
+ template <typename I>
+ inline
+ mln_lvalue(I) value_impl(trait::image::category::any,
+ Image<I>& ima)
+ {
+ mlc_is(mln_trait_image_value_storage(I),
+ trait::image::value_storage::singleton)::check();
+ return exact(ima).value_();
+ }
+ }
+
+
+ template <typename I>
+ inline
+ mln_rvalue(I) value(const Image<I>& ima)
+ {
+ return impl::value_impl(mln_trait_image_category(I)(), ima);
+ }
+
+ template <typename I>
+ inline
+ mln_lvalue(I) value(Image<I>& ima)
+ {
+ return impl::value_impl(mln_trait_image_category(I)(), ima);
+ }
+
+
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::opt
+
+} // end of namespace mln
+
+
+#endif // ! MLN_OPT_VALUE_HH
Index: mln/value/sign.hh
--- mln/value/sign.hh (revision 3149)
+++ mln/value/sign.hh (working copy)
@@ -52,7 +52,7 @@
class sign : public internal::Integer<sign>
{
public:
- /// FIXME is these typedefs correct?
+ /// FIXME Are these typedefs correct?
/// Define the encoding type
typedef int enc;
Index: tests/core/image/flat_image.cc
--- tests/core/image/flat_image.cc (revision 3149)
+++ tests/core/image/flat_image.cc (working copy)
@@ -51,7 +51,7 @@
{
val = 9;
- test.val() = 9;
+ test.value_() = 9;
mln_piter_(I) p(test.domain());
for_all(p)
mln_assertion(test(p) == val);
Index: tests/opt/value.cc
--- tests/opt/value.cc (revision 0)
+++ tests/opt/value.cc (revision 0)
@@ -0,0 +1,52 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+// (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/// \file tests/opt/at.cc
+///
+/// Tests on mln::opt::at.
+
+#include <mln/opt/value.hh>
+#include <mln/core/image/flat_image.hh>
+#include <mln/core/alias/box2d.hh>
+
+#include <mln/trace/all.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ short val = 6;
+ typedef flat_image<short, box2d> I;
+ I ima(val, box2d(3, 4));
+
+ opt::value(ima) = 51;
+ mln_precondition(opt::value(ima) == 51);
+
+
+}