* mln/algebra/vec.hh,
* mln/value/int_u.hh,
* mln/value/rgb.hh: Interopability with different quantizations.
---
milena/mln/algebra/vec.hh | 11 +++++++++++
milena/mln/value/int_u.hh | 15 +++++++++++++++
milena/mln/value/rgb.hh | 27 +++++++++++++++++++++++++--
3 files changed, 51 insertions(+), 2 deletions(-)
diff --git a/milena/mln/algebra/vec.hh b/milena/mln/algebra/vec.hh
index 22ebc02..598c318 100644
--- a/milena/mln/algebra/vec.hh
+++ b/milena/mln/algebra/vec.hh
@@ -198,6 +198,8 @@ namespace mln
vec& operator=(const literal::origin_t&);
/// \}
+ vec(const literal::one_t&);
+
vec(const vec<n, T>& rhs);
template <typename U>
@@ -448,6 +450,13 @@ namespace mln
{
this->set_all(0);
}
+
+ template <unsigned n, typename T>
+ inline
+ vec<n,T>::vec(const literal::one_t&)
+ {
+ this->set_all(1);
+ }
template <unsigned n, typename T>
inline
@@ -474,6 +483,8 @@ namespace mln
return *this;
}
+
+
template <unsigned n, typename T>
inline
vec<n,T>::vec(const vec<n,T>& rhs)
diff --git a/milena/mln/value/int_u.hh b/milena/mln/value/int_u.hh
index f3786f9..bf0b139 100644
--- a/milena/mln/value/int_u.hh
+++ b/milena/mln/value/int_u.hh
@@ -181,6 +181,12 @@ namespace mln
int_u& operator=(const mln::literal::one_t&);
/// \}
+ template <unsigned m>
+ int_u(const int_u<m>& other)
+ {
+ this->handle_() = static_cast<enc_>(other.to_enc());
+ }
+
/// Conversion to an unsigned integer.
operator unsigned() const;
@@ -262,6 +268,15 @@ namespace mln
to_ = static_cast<double>(from);
}
+ template <unsigned n, unsigned n2>
+ inline
+ void
+ from_to_(const value::int_u<n>& from, value::int_u<n2>& to_)
+ {
+ to_ = static_cast<unsigned>(from);
+ }
+
+
} // end of namespace mln::convert::over_load
diff --git a/milena/mln/value/rgb.hh b/milena/mln/value/rgb.hh
index c9d2f53..d1729a7 100644
--- a/milena/mln/value/rgb.hh
+++ b/milena/mln/value/rgb.hh
@@ -283,7 +283,9 @@ namespace mln
/// Constructor from a algebra::vec.
rgb<n>(const algebra::vec<3, int>& rhs);
rgb<n>(const algebra::vec<3, unsigned>& rhs);
- rgb<n>(const algebra::vec<3, int_u<n> >& rhs);
+
+ template <unsigned m>
+ rgb<n>(const algebra::vec<3, int_u<m> >& rhs);
rgb<n>(const algebra::vec<3, float>& rhs);
// Conversion to the interoperation type.
@@ -316,10 +318,16 @@ namespace mln
/// \}
/// Assignment.
+ template <unsigned m>
+ rgb<n>& operator=(const rgb<m>& rhs);
+
rgb<n>& operator=(const rgb<n>& rhs);
/// Zero value.
static const rgb<n> zero;
+
+ // friend class access
+ template <unsigned> friend struct rgb;
};
@@ -438,8 +446,9 @@ namespace mln
}
template <unsigned n>
+ template <unsigned m>
inline
- rgb<n>::rgb(const algebra::vec<3, int_u<n> >& v)
+ rgb<n>::rgb(const algebra::vec<3, int_u<m> >& v)
{
this->v_ = v;
}
@@ -639,6 +648,18 @@ namespace mln
this->v_[2] = 0;
}
+
+
+ template <unsigned n>
+ template <unsigned m>
+ inline
+ rgb<n>&
+ rgb<n>::operator=(const rgb<m>& rhs)
+ {
+ this->v_ = rhs.v_;
+ return *this;
+ }
+
template <unsigned n>
inline
rgb<n>&
@@ -650,6 +671,8 @@ namespace mln
return *this;
}
+
+
template <unsigned n>
const rgb<n> rgb<n>::zero(0,0,0);
--
1.7.2.5