https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Update interpolated and tr_image morphers.
* mln/core/image/tr_image.hh: Update (traits ...) .
* mln/core/image/interpolated.hh (operator()): Add non const version.
interpolated.hh | 14 ++++--
tr_image.hh | 117 ++++++++++++++++++++++++++++++++++----------------------
2 files changed, 81 insertions(+), 50 deletions(-)
Index: mln/core/image/tr_image.hh
--- mln/core/image/tr_image.hh (revision 2404)
+++ mln/core/image/tr_image.hh (working copy)
@@ -46,35 +46,49 @@
{
// Fwd decl.
- template <typename T, typename I> struct tr_image;
+ template <typename S, typename I, typename T> struct tr_image;
namespace internal
{
/// Data structure for \c mln::tr_image<T,I>.
- template <typename T, typename I>
- struct data< tr_image<T,I> >
+ template <typename S, typename I, typename T>
+ struct data< tr_image<S,I,T> >
{
- data(I& ima, T& tr);
+ data(const S& s,I& ima, const T& tr);
I ima_;
T tr_;
+ S s_;
};
} // end of namespace mln::internal
+ namespace trait
+ {
+
+ template <typename S, typename I, typename T>
+ struct image_< tr_image<S,I,T> >
+ : public image_<I> // Same as I except...
+ {
+ // ...these changes.
+ typedef trait::image::value_io::read_only value_io;
+ };
+
+ } // end of namespace mln::trait
+
/*! \brief Morpher that makes an image become transformed by a given
* transformation.
*
*/
- template <typename T, typename I>
+ template <typename S, typename I, typename T>
struct tr_image :
- public mln::internal::image_identity< I, mln_pset(I), tr_image<T,I> >
+ public mln::internal::image_identity< I, mln_pset(I), tr_image<S,I,T> >
{
/// Super type.
typedef
- mln::internal::image_identity< I, mln_pset(I), tr_image<T,I> > super_;
+ mln::internal::image_identity< I, mln_pset(I), tr_image<S,I,T> > super_;
/// Point_Site associated type.
typedef mln_psite(I) psite;
@@ -89,11 +103,11 @@
typedef mln_rvalue(I) rvalue;
/// Skeleton.
- typedef tr_image< T, tag::image_<I> > skeleton;
+ typedef tr_image< S, tag::image_<I>, T> skeleton;
/// Constructors.
- tr_image(I& ima, T& tr);
+ tr_image(const S& s, I& ima, const T& tr);
/* FIXME: What's the purpose of this ctor? AFAIK, morphers
objects (and images in general) cannot have their structure /
core data altered after they're built. Here, there's a
@@ -103,6 +117,8 @@
tr_image();
+ void init_(const S& s, I& ima, const T& tr);
+
/// Test if this image has been initialized.
bool has_data() const;
@@ -110,18 +126,14 @@
using super_::has;
/// Test if a pixel value is accessible at \p v.
- bool has(const mln::algebra::vec<I::point::dim, float>& v) const;
-
- using super_::has;
-
- /// Test if a pixel value is belonging to image at \p v.
- bool has(const mln::algebra::vec<I::point::dim, float>& v) const;
+ bool has(const mln::algebra::vec<I::psite::dim, float>& v) const;
/// Read-only access of pixel value at point site \p p.
/// Mutable access is only OK for reading (not writing).
using super_::operator();
- mln_value(I) operator()(const mln::algebra::vec<I::point::dim, float>& v)
const;
+ mln_value(I) operator()(const psite& p);
+ mln_value(I) operator()(const psite& p) const;
void set_tr(T& tr);
};
@@ -135,41 +147,50 @@
// internal::data< tr_image<I,S> >
- template <typename T, typename I>
+ template <typename S, typename I, typename T>
inline
- data< tr_image<T,I> >::data(I& ima, T& tr)
+ data< tr_image<S,I,T> >::data(const S& s, I& ima, const T&
tr)
: ima_(ima),
- tr_(tr)
+ tr_(tr),
+ s_(s)
{
}
} // end of namespace mln::internal
- template <typename T, typename I>
+ template <typename S, typename I, typename T>
+ inline
+ tr_image<S,I,T>::tr_image(const S& s, I& ima, const T& tr)
+ {
+ mln_precondition(ima.has_data());
+ this->data_ = new internal::data< tr_image<S,I,T> >(s, ima, tr);
+ }
+
+ template <typename S, typename I, typename T>
inline
- tr_image<T,I>::tr_image(I& ima, T& tr)
+ void tr_image<S,I,T>::init_(const S& s, I& ima, const T& tr)
{
mln_precondition(ima.has_data());
- this->data_ = new internal::data< tr_image<T,I> >(ima, tr);
+ this->data_ = new internal::data< tr_image<S,I,T> >(s, ima, tr);
}
- template <typename T, typename I>
+ template <typename S, typename I, typename T>
inline
- tr_image<T,I>::tr_image()
+ tr_image<S,I,T>::tr_image()
{
}
- template <typename T, typename I>
+ template <typename S, typename I, typename T>
inline
- bool tr_image<T,I>::has_data() const
+ bool tr_image<S,I,T>::has_data() const
{
mln_invariant(this->delegatee_()->has_data());
return true;
}
- template <typename T, typename I>
+ template <typename S, typename I, typename T>
inline
- bool tr_image<T,I>::has(const algebra::vec<I::point::dim, float>& v)
const
+ bool tr_image<S,I,T>::has(const algebra::vec<I::psite::dim, float>& v)
const
{
mln_psite(I) p;
algebra::vec<I::point::dim, float> v2 = this->data_->tr_.inv()(v);
@@ -178,38 +199,44 @@
return this->delegatee_().has(p);
}
- template <typename T, typename I>
+
+ template <typename S, typename I, typename T>
inline
- bool tr_image<T,I>::has(const algebra::vec<I::point::dim, float>& v)
const
+ mln_value(I)
+ tr_image<S,I,T>::operator()(const psite& p) const
{
- mln_psite(I) p;
- algebra::vec<I::point::dim, float> v2 = this->data_->tr_.inv()(v);
- for (unsigned i = 0; i < I::point::dim; ++i)
- p[i] = static_cast<int>(round(v2[i]));
- return this->delegatee_()->domain().has(p);
+ std::cout << "yay" << std::endl;
+ algebra::vec<I::psite::dim, float> v = p;
+ return this->data_->ima_(this->data_->tr_.inv()(v));
}
- template <typename T, typename I>
+ template <typename S, typename I, typename T>
inline
mln_value(I)
- tr_image<T,I>::operator()(const algebra::vec<I::point::dim, float>& v)
const
+ tr_image<S,I,T>::operator()(const psite& p)
{
- mln_psite(I) p;
- algebra::vec<I::point::dim, float> v2 = this->data_->tr_.inv()(v);
- for (unsigned i = 0; i < I::point::dim; ++i)
- p[i] = static_cast<int>(round(v2[i]));
- mln_assertion(this->delegatee_()->has(p));
- return (*this->delegatee_())(p);
+ std::cout << "yay" << std::endl;
+ algebra::vec<I::psite::dim, float> v = p;
+ return this->data_->ima_(this->data_->tr_.inv()(v));
}
- template <typename T, typename I>
+ template <typename S, typename I, typename T>
inline
void
- tr_image<T,I>::set_tr(T& tr)
+ tr_image<S,I,T>::set_tr(T& tr)
{
this->data_->tr_ = tr;
}
+ template <typename S, typename I, typename T>
+ inline
+ tr_image<S,I,T>
+ transposed_image(const Site_Set<S>& s, Image<I>& ima, const
Function_x2x<T>& t)
+ {
+ tr_image<S,I,T> tmp(exact(s), exact(ima), exact(t));
+ return tmp;
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
Index: mln/core/image/interpolated.hh
--- mln/core/image/interpolated.hh (revision 2404)
+++ mln/core/image/interpolated.hh (working copy)
@@ -126,6 +126,7 @@
using super_::operator();
mln_value(I) operator()(const mln::algebra::vec<I::psite::dim, float>& v)
const;
+ mln_value(I) operator()(const mln::algebra::vec<I::psite::dim, float>& v);
const F<I> fun_;
};
@@ -195,11 +196,14 @@
mln_value(I)
interpolated<I,F>::operator()(const mln::algebra::vec<I::psite::dim,
float>& v) const
{
- // mln_psite(I) p;
- // for (unsigned i = 0; i < I::point::dim; ++i)
- // p[i] = static_cast<int>(round(v[i]));
- // mln_assertion(this->data_->ima_.has(p));
- // return this->data_->ima_(p);
+ return fun_(v);
+ }
+
+ template <typename I, template <class> class F>
+ inline
+ mln_value(I)
+ interpolated<I,F>::operator()(const mln::algebra::vec<I::psite::dim,
float>& v)
+ {
return fun_(v);
}