https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Make erosion work on nD images.
* mln/core/image/image1d.hh: Layout doc.
(element): Precise doc. Fix precondition.
(element): Rename ind as i (less ambiguous).
* mln/core/image/image3d.hh: Fix doc.
(element): Rename o as i to be consistent.
* mln/border/fill.hh (fill_size_n): Factor const cast.
* mln/win/segment1d.hh: Upgrade doc style.
* mln/win/line.hh: Likewise.
* mln/morpho/erosion.spe.hh: Likewise.
(erosion_chooses_arbitrary): Remove; such a test has to be a
static chek (at compile-time!)
(erosion_dispatch_wrt_arbitrary_win): New.
(erosion_dispatch_wrt_win): Turn dispatch into static.
border/fill.hh | 6 ++--
core/image/image1d.hh | 27 ++++++++++---------
core/image/image3d.hh | 29 +++++++++++---------
morpho/erosion.spe.hh | 70 +++++++++++++++++++++++++-------------------------
win/line.hh | 10 +++----
win/segment1d.hh | 8 ++---
6 files changed, 79 insertions(+), 71 deletions(-)
Index: mln/core/image/image1d.hh
--- mln/core/image/image1d.hh (revision 2836)
+++ mln/core/image/image1d.hh (working copy)
@@ -30,7 +30,8 @@
# define MLN_CORE_IMAGE_IMAGE1D_HH
/// \file mln/core/image/image1d.hh
-/// \brief Definition of the basic mln::image1d class.
+///
+/// Definition of the basic mln::image1d class.
# include <mln/core/internal/fixme.hh>
# include <mln/core/internal/image_primary.hh>
@@ -206,11 +207,13 @@
/// Give a hook to the value buffer.
T* buffer();
- /// Read-only access to the image value located at (\p ind).
- const T& element(unsigned ind) const;
-
- /// Read-write access to the image value located at (\p ind).
- T& element(unsigned ind);
+ /// Read-only access to the \p i-th image value (including the
+ /// border).
+ const T& element(unsigned i) const;
+
+ /// Read-write access to the \p i-th image value (including the
+ /// border).
+ T& element(unsigned i);
/// Give the number of cells (points including border ones).
unsigned nelements() const;
@@ -445,19 +448,19 @@
template <typename T>
inline
const T&
- image1d<T>::element(unsigned ind) const
+ image1d<T>::element(unsigned i) const
{
- mln_precondition(this->has(point1d(ind)));
- return this->data_->buffer_[ind];
+ mln_precondition(i < nelements());
+ return this->data_->buffer_[i];
}
template <typename T>
inline
T&
- image1d<T>::element(unsigned ind)
+ image1d<T>::element(unsigned i)
{
- mln_precondition(this->has(point1d(ind)));
- return this->data_->buffer_[ind];
+ mln_precondition(i < nelements());
+ return this->data_->buffer_[i];
}
template <typename T>
Index: mln/core/image/image3d.hh
--- mln/core/image/image3d.hh (revision 2836)
+++ mln/core/image/image3d.hh (working copy)
@@ -30,7 +30,8 @@
# define MLN_CORE_IMAGE_IMAGE3D_HH
/// \file mln/core/image/image3d.hh
-/// \brief Definition of the basic mln::image3d class.
+///
+/// Definition of the basic mln::image3d class.
# include <mln/core/internal/fixme.hh>
# include <mln/core/internal/image_primary.hh>
@@ -192,16 +193,18 @@
/// Read-write access to the image value located at point \p p.
T& operator()(const point3d& p);
- /// Read-only access to the image value located at offset \p o.
- const T& element(unsigned o) const;
+ /// Read-only access to the image value located at index \p i.
+ const T& element(unsigned i) const;
- /// Read-write access to the image value located at offset \p o.
- T& element(unsigned o);
+ /// Read-write access to the image value located at index \p i.
+ T& element(unsigned i);
- /// Read-only access to the image value located at (\p ind).
+ /// Read-only access to the image value located at (\p sli, \p
+ /// row, \p col).
const T& at(int sli, int row, int col) const;
- /// Read-write access to the image value located at (\p ind).
+ /// Read-write access to the image value located at (\p sli, \p
+ /// row, \p col).
T& at(int sli, int row, int col);
@@ -463,19 +466,19 @@
template <typename T>
inline
const T&
- image3d<T>::element(unsigned o) const
+ image3d<T>::element(unsigned i) const
{
- mln_precondition(o < nelements());
- return *(data_->buffer_ + o);
+ mln_precondition(i < nelements());
+ return *(data_->buffer_ + i);
}
template <typename T>
inline
T&
- image3d<T>::element(unsigned o)
+ image3d<T>::element(unsigned i)
{
- mln_precondition(o < nelements());
- return *(data_->buffer_ + o);
+ mln_precondition(i < nelements());
+ return *(data_->buffer_ + i);
}
template <typename T>
Index: mln/border/fill.hh
--- mln/border/fill.hh (revision 2836)
+++ mln/border/fill.hh (working copy)
@@ -117,7 +117,7 @@
{
trace::entering("border::impl::fill_size_n");
- const I& ima = exact(ima_);
+ I& ima = const_cast<I&>( exact(ima_) );
internal::fill_tests(ima, v);
typedef mln_psite(I) P;
@@ -129,11 +129,11 @@
{
unsigned end = ima.index_of_point (pl);
for (unsigned i = st; i < end; ++i)
- (const_cast<I&>(ima)).element(i) = v;
+ ima.element(i) = v;
st = end + len_r;
}
for (unsigned i = st; i < ima.nelements (); ++i)
- const_cast<I&>(ima).element(i) = v;
+ ima.element(i) = v;
trace::exiting("border::impl::fill_size_n");
}
Index: mln/win/segment1d.hh
--- mln/win/segment1d.hh (revision 2836)
+++ mln/win/segment1d.hh (working copy)
@@ -1,4 +1,5 @@
// 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
@@ -28,10 +29,9 @@
#ifndef MLN_WIN_SEGMENT1D_HH
# define MLN_WIN_SEGMENT1D_HH
-/*! \file mln/win/segment1d.hh
- *
- * \brief Definition of the mln::win::segment1d window.
- */
+/// \file mln/win/segment1d.hh
+///
+/// Definition of the mln::win::segment1d window.
# include <mln/win/line.hh>
# include <mln/core/grids.hh>
Index: mln/win/line.hh
--- mln/win/line.hh (revision 2836)
+++ mln/win/line.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+// 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
@@ -28,10 +29,9 @@
#ifndef MLN_WIN_LINE_HH
# define MLN_WIN_LINE_HH
-/*! \file mln/win/line.hh
- *
- * \brief Definition of the mln::win::line window.
- */
+/// \file mln/win/line.hh
+///
+/// Definition of the mln::win::line window.
# include <mln/core/internal/classical_window_base.hh>
# include <mln/core/dpoint.hh>
Index: mln/morpho/erosion.spe.hh
--- mln/morpho/erosion.spe.hh (revision 2836)
+++ mln/morpho/erosion.spe.hh (working copy)
@@ -52,13 +52,13 @@
# include <mln/canvas/browsing/backdiagonal2d.hh>
-/*! \file mln/morpho/erosion.spe.hh
- *
- * \brief Specialization for mln::morpho::erosion.
- *
- * \todo Warning: we should also have the "arbitrary" versions working
- * on sets (not only on functions!)
- */
+/// \file mln/morpho/erosion.spe.hh
+///
+/// Specialization for mln::morpho::erosion.
+///
+/// \todo Warning: we should also have the "arbitrary" versions working
+/// on sets (not only on functions!)
+
# ifndef MLN_INCLUDE_ONLY
@@ -1231,26 +1231,6 @@
// dispatch for arbitrary elements
template <typename I, typename W>
- bool
- erosion_chooses_arbitrary(const I&, const W& win)
- {
- return
- win.size() >= 10 // size is not too small
- &&
- // 2d case only
- mlc_equal(mln_trait_image_dimension(I),
- trait::image::dimension::two_d)::value
- &&
- // on a grid
- mlc_is_a(mln_site(I),
- Gpoint)::value
- &&
- // continuous data
- mlc_not_equal(mln_trait_image_value_storage(I),
- trait::image::value_storage::disrupted)::value;
- }
-
- template <typename I, typename W>
mln_concrete(I)
erosion_dispatch_for_arbitrary(trait::image::speed::fastest,
const I& input, const W& win)
@@ -1372,22 +1352,44 @@
return ima;
}
+
// dispatch w.r.t. win
+
template <typename I, typename W>
mln_concrete(I)
- erosion_dispatch_wrt_win(const I& input, const W& win)
+ erosion_dispatch_wrt_arbitrary_win(metal::true_,
+ const I& input, const W& win)
{
- // FIXME: De-activate because, when win is multiple,
- // win::shift does not work. We have to introduce
- // props from windows, then re-write win::shift.
-
- if (erosion_chooses_arbitrary(input, win))
return erosion_dispatch_for_arbitrary(input, win);
- else
+ }
+
+ template <typename I, typename W>
+ mln_concrete(I)
+ erosion_dispatch_wrt_arbitrary_win(metal::false_,
+ const I& input, const W& win)
+ {
return erosion_dispatch_for_generic(input, win);
}
+ template <typename I, typename W>
+ mln_concrete(I)
+ erosion_dispatch_wrt_win(const I& input, const W& win)
+ {
+ // FIXME:
+ // The test "win.size() >= 10" (size is not too small) has been
+ // de-activated...
+ enum { test = mlc_equal(mln_trait_image_dimension(I),
+ trait::image::dimension::two_d)::value
+ &&
+ mlc_is_a(mln_site(I), Gpoint)::value
+ &&
+ mlc_not_equal(mln_trait_image_value_storage(I),
+ trait::image::value_storage::disrupted)::value };
+ return erosion_dispatch_wrt_arbitrary_win(metal::bool_<test>(),
+ input, win);
+ }
+
template <typename I>
mln_concrete(I)
erosion_dispatch_wrt_win(const I& input, const win::rectangle2d& win)