https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add image selection about different kinds of values and update.
* oln/core/concept/image.hh (Gray_Level_Image, Color_Image)
(Label_Image, Binary_Image, String_Image)
(Deformation_Field_Image, Data_Image): New.
* oln/core/internal/max_value.hh: Fix.
* oln/core/internal/image_selectors.hh (Image_value_kind): New.
* oln/morpho/dilation.hh: Fix.
* oln/morpho/elementary_erosion.hh (elementary_erosion_): Rename as...
(elementary_erosion_on_function_): ...this.
(elementary_erosion_on_set_): New.
(elementary_erosion_): Dispatch over function/set.
(elementary_erosion): Update.
* oln/level/local.hh (A): Rename as...
(F): ...this.
* oln/accumulator/max.hh,
* oln/core/internal/min_value.hh,
* oln/morpho/elementary_dilation.hh: New.
* oln/value/greylevel.hh: Rename as...
* oln/value/graylevel.hh: ...this.
(greylevel_, greylevel): Rename as...
(graylevel_, graylevel): ...these.
* oln/value/default.hh (greylevel): Rename as...
(graylevel): ...this.
* oln/value/all.hh (include): Update.
* oln/value/bin.hh (bin): Change from greylevel_<1> to
graylevel_<1>.
* oln/value/tags.hh (is_grey_level): Rename as...
(is_gray_level): ...this.
accumulator/max.hh | 95 ++++++++++++++++++
core/concept/image.hh | 113 ++++++++++++++++++++++
core/internal/image_selectors.hh | 53 ++++++++++
core/internal/max_value.hh | 12 --
core/internal/min_value.hh | 35 ++++++
level/local.hh | 18 +--
morpho/dilation.hh | 79 +++++++++++++--
morpho/elementary_dilation.hh | 112 ++++++++++++++++++++++
morpho/elementary_erosion.hh | 28 ++++-
value/all.hh | 2
value/bin.hh | 4
value/default.hh | 10 -
value/graylevel.hh | 198 +++++++++++++++++++--------------------
value/tags.hh | 30 ++++-
14 files changed, 640 insertions(+), 149 deletions(-)
Index: oln/accumulator/max.hh
--- oln/accumulator/max.hh (revision 0)
+++ oln/accumulator/max.hh (revision 0)
@@ -0,0 +1,95 @@
+// 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 OLN_ACCUMULATOR_MAX_HH
+# define OLN_ACCUMULATOR_MAX_HH
+
+# include <oln/core/concept/accumulator.hh>
+# include <oln/core/internal/min_value.hh>
+
+
+namespace oln
+{
+
+ namespace accumulator
+ {
+
+ template <typename T>
+ struct max_ : public Accumulator< max_<T> >
+ {
+ typedef T argument;
+ typedef T result;
+
+ max_();
+
+ void init() const;
+ const T& value() const;
+
+ void operator()(const T& val) const;
+
+ private:
+ mutable T val_;
+ };
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename T>
+ max_<T>::max_()
+ {
+ this->init();
+ }
+
+ template <typename T>
+ void
+ max_<T>::init() const
+ {
+ this->val_ = oln_min(T);
+ }
+
+ template <typename T>
+ const T&
+ max_<T>::value() const
+ {
+ return this->val_;
+ }
+
+ template <typename T>
+ void
+ max_<T>::operator()(const T& val) const
+ {
+ if (val > this->val_)
+ this->val_ = val;
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
+
+ } // end of namespace oln::accumulator
+
+} // end of namespace oln
+
+#endif // ! OLN_ACCUMULATOR_MAX_HH
Index: oln/core/concept/image.hh
--- oln/core/concept/image.hh (revision 891)
+++ oln/core/concept/image.hh (working copy)
@@ -351,6 +351,69 @@
+ /// Concept-class "Gray_Level_Image".
+
+ template <typename Exact>
+ struct Gray_Level_Image : public virtual Image<Exact>
+ {
+ protected:
+ Gray_Level_Image();
+ };
+
+ /// Concept-class "Color_Image".
+
+ template <typename Exact>
+ struct Color_Image : public virtual Image<Exact>
+ {
+ protected:
+ Color_Image();
+ };
+
+ /// Concept-class "Label_Image".
+
+ template <typename Exact>
+ struct Label_Image : public virtual Image<Exact>
+ {
+ protected:
+ Label_Image();
+ };
+
+ /// Concept-class "Binary_Image".
+
+ template <typename Exact>
+ struct Binary_Image : public Label_Image<Exact>
+ {
+ protected:
+ Binary_Image();
+ };
+
+ /// Concept-class "String_Image".
+
+ template <typename Exact>
+ struct String_Image : public Label_Image<Exact>
+ {
+ protected:
+ String_Image();
+ };
+
+ /// Concept-class "Deformation_Field_Image".
+
+ template <typename Exact>
+ struct Deformation_Field_Image : public virtual Image<Exact>
+ {
+ protected:
+ Deformation_Field_Image();
+ };
+
+ /// Concept-class "Data_Image".
+
+ template <typename Exact>
+ struct Data_Image : public virtual Image<Exact>
+ {
+ protected:
+ Data_Image();
+ };
+
@@ -613,6 +676,56 @@
{
}
+ // ----------------------------------- Gray_Level_Image<Exact>
+
+ template <typename Exact>
+ Gray_Level_Image<Exact>::Gray_Level_Image()
+ {
+ }
+
+ // ----------------------------------- Color_Image<Exact>
+
+ template <typename Exact>
+ Color_Image<Exact>::Color_Image()
+ {
+ }
+
+ // ----------------------------------- Label_Image<Exact>
+
+ template <typename Exact>
+ Label_Image<Exact>::Label_Image()
+ {
+ }
+
+ // ----------------------------------- Binary_Image<Exact>
+
+ template <typename Exact>
+ Binary_Image<Exact>::Binary_Image()
+ {
+ }
+
+ // ----------------------------------- String_Image<Exact>
+
+ template <typename Exact>
+ String_Image<Exact>::String_Image()
+ {
+ }
+
+ // ----------------------------------- Deformation_Field_Image<Exact>
+
+ template <typename Exact>
+ Deformation_Field_Image<Exact>::Deformation_Field_Image()
+ {
+ }
+
+ // ----------------------------------- Data_Image<Exact>
+
+ template <typename Exact>
+ Data_Image<Exact>::Data_Image()
+ {
+ }
+
+
# endif // OLN_INCLUDE_ONLY
} // end of namespace oln
Index: oln/core/internal/max_value.hh
--- oln/core/internal/max_value.hh (revision 891)
+++ oln/core/internal/max_value.hh (working copy)
@@ -25,17 +25,11 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_INTERNAL_MAX_VALUE_HH_
-# define OLN_CORE_INTERNAL_MAX_VALUE_HH_
+#ifndef OLN_CORE_INTERNAL_MAX_VALUE_HH
+# define OLN_CORE_INTERNAL_MAX_VALUE_HH
-#include <cassert>
#include <limits>
-namespace oln
-{
-
#define oln_max(T) std::numeric_limits<T>::max()
-}
-
-#endif /* !OLN_CORE_INTERNAL_MAX_VALUE_HH_ */
+#endif // ! OLN_CORE_INTERNAL_MAX_VALUE_HH
Index: oln/core/internal/image_selectors.hh
--- oln/core/internal/image_selectors.hh (revision 891)
+++ oln/core/internal/image_selectors.hh (working copy)
@@ -30,6 +30,7 @@
# include <oln/core/concept/image.hh>
# include <oln/core/2d/grid2d.hh>
+# include <oln/value/tags.hh>
namespace oln
@@ -136,6 +137,58 @@
};
+ // 6. value kind
+
+ typedef selector<Image, 6> Image_value_kind;
+
+ template <typename Exact>
+ struct case_< Image_value_kind, Exact, 1 >
+ :
+ where_< value::is_gray_level<stc_get_type(value)> >
+ {
+ typedef Gray_Level_Image<Exact> ret;
+ };
+
+ template <typename Exact>
+ struct case_< Image_value_kind, Exact, 2 >
+ :
+ where_< value::is_binary<stc_get_type(value)> >
+ {
+ typedef Binary_Image<Exact> ret;
+ };
+
+ template <typename Exact>
+ struct case_< Image_value_kind, Exact, 3 >
+ :
+ where_< value::is_string<stc_get_type(value)> >
+ {
+ typedef String_Image<Exact> ret;
+ };
+
+ template <typename Exact>
+ struct case_< Image_value_kind, Exact, 4 >
+ :
+ where_< value::is_label<stc_get_type(value)> >
+ {
+ typedef Label_Image<Exact> ret;
+ };
+
+ template <typename Exact>
+ struct case_< Image_value_kind, Exact, 5 >
+ :
+ where_< value::is_color<stc_get_type(value)> >
+ {
+ typedef Color_Image<Exact> ret;
+ };
+
+ // FIXME: Deformation_Field_Image
+
+ template <typename Exact>
+ struct default_case_< Image_value_kind, Exact >
+ {
+ typedef Data_Image<Exact> ret;
+ };
+
} // end of namespace oln::internal
Index: oln/core/internal/min_value.hh
--- oln/core/internal/min_value.hh (revision 0)
+++ oln/core/internal/min_value.hh (revision 0)
@@ -0,0 +1,35 @@
+// 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 OLN_CORE_INTERNAL_MIN_VALUE_HH
+# define OLN_CORE_INTERNAL_MIN_VALUE_HH
+
+# include <limits>
+
+# define oln_min(T) std::numeric_limits< T >::min()
+
+# endif // ! OLN_CORE_INTERNAL_MIN_VALUE_HH
Index: oln/morpho/dilation.hh
--- oln/morpho/dilation.hh (revision 891)
+++ oln/morpho/dilation.hh (working copy)
@@ -1,29 +1,84 @@
-#ifndef OLN_MORPHOMATH_DILATATION_HH_
-# define OLN_MORPHOMATH_DILATATION_HH_
+// 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 OLN_MORPHO_DILATION_HH
+# define OLN_MORPHO_DILATION_HH
+
+#include <oln/level/apply_local.hh>
+#include <oln/border/fill.hh>
+#include <oln/accumulator/max.hh>
-// Facade.
+
+ namespace morpho
+ {
+
+ // Fwd decl.
+
+ template <typename I, typename W>
+ oln_plain(I)
+ dilation(const Image<I>& input, const Window<W>& win);
+
+
+# ifndef OLN_INCLUDE_ONLY
namespace impl
{
- /// Generic version
+ // Generic version.
template <typename I, typename W>
- I dilatation(const Image<I>& input)
+ oln_plain(I)
+ elementary_dilation_(const Image<I>& input,
+ const Window<W>& win)
{
- max_<oln_value(I)> max;
- return apply(max, input);
+ border::fill(input, oln_min(oln_value(I)));
+ accumulator::max_<oln_value(I)> max;
+ return level::apply_local(max, input, win);
}
-}
+ // FIXME: Add a fast version.
+
+ } // end of namespace oln::morpho::impl
-/// Facade.
+ // Facade.
template <typename I, typename W>
-I erosion(const Image<I>& input)
+ oln_plain(I)
+ dilation(const Image<I>& input, const Window<W>& win)
{
- return impl::dilatation(exact(input));
+ return impl::dilation_(exact(input), exact(win));
}
-#endif /* !OLN_MORPHOMATH_DILATATION_HH_ */
+# endif // ! OLN_INCLUDE_ONLY
+
+ } // end of namespace oln::morpho
+
+} // end of namespace oln
+
+
+#endif // ! OLN_MORPHO_DILATION_HH
Index: oln/morpho/elementary_erosion.hh
--- oln/morpho/elementary_erosion.hh (revision 891)
+++ oln/morpho/elementary_erosion.hh (working copy)
@@ -55,7 +55,7 @@
template <typename I>
oln_plain(I)
- elementary_erosion_(const Image<I>&,
+ elementary_erosion_on_function_(const Image<I>&,
const I& input)
{
border::fill(input, oln_max(oln_value(I)));
@@ -63,13 +63,22 @@
return level::apply_local(min, input);
}
+ template <typename I>
+ oln_plain(I)
+ elementary_erosion_on_set_(const Image<I>&,
+ const I&)
+ {
+ oln_plain(I) tmp;
+ std::cerr << "morpho::impl::elementary_erosion_on_set_ is not yet
impled!" << std::endl;
+ return tmp;
+ }
// Fast version.
// template <typename I>
// oln_plain(I)
-// elementary_erosion_(const /*Fast_*/Image<I>&,
+// elementary_erosion_on_function_(const /*Fast_*/Image<I>&,
// const I& input)
// {
// std::cout << "fast" << std::endl;
@@ -100,6 +109,19 @@
// }
+ // Impl facade.
+
+ template <typename I>
+ oln_plain(I) elementary_erosion_(const Image<I>& input)
+ {
+ return elementary_erosion_on_function_(exact(input), exact(input));
+ }
+
+ template <typename I>
+ oln_plain(I) elementary_erosion_(const Binary_Image<I>& input)
+ {
+ return elementary_erosion_on_set_(exact(input), exact(input));
+ }
} // end of namespace oln::morpho::impl
@@ -111,7 +133,7 @@
oln_plain(I)
elementary_erosion(const Image_with_Nbh<I>& input)
{
- return impl::elementary_erosion_(exact(input), exact(input));
+ return impl::elementary_erosion_(exact(input));
}
# endif // ! OLN_INCLUDE_ONLY
Index: oln/morpho/elementary_dilation.hh
--- oln/morpho/elementary_dilation.hh (revision 0)
+++ oln/morpho/elementary_dilation.hh (revision 0)
@@ -0,0 +1,112 @@
+// 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 OLN_MORPHO_ELEMENTARY_DILATION_HH
+# define OLN_MORPHO_ELEMENTARY_DILATION_HH
+
+#include <oln/level/apply_local.hh>
+#include <oln/border/fill.hh>
+#include <oln/accumulator/max.hh>
+
+
+namespace oln
+{
+
+ namespace morpho
+ {
+
+ // Fwd decl.
+
+ template <typename I>
+ oln_plain(I)
+ elementary_dilation(const Image_with_Nbh<I>& input);
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ // Generic version.
+
+ template <typename I>
+ oln_plain(I)
+ elementary_dilation_on_function_(const Image<I>&,
+ const I& input)
+ {
+ border::fill(input, oln_min(oln_value(I)));
+ accumulator::max_<oln_value(I)> max;
+ return level::apply_local(max, input);
+ }
+
+ template <typename I>
+ oln_plain(I)
+ elementary_dilation_on_set_(const Image<I>&,
+ const I&)
+ {
+ oln_plain(I) tmp;
+ std::cerr << "morpho::impl::elementary_dilation_on_set_ is not yet
impled!" << std::endl;
+ return tmp;
+ }
+
+ // FIXME: Add a fast version.
+
+
+ // Impl facade.
+
+ template <typename I>
+ oln_plain(I) elementary_dilation_(const Image<I>& input)
+ {
+ return elementary_dilation_on_function_(exact(input), exact(input));
+ }
+
+ template <typename I>
+ oln_plain(I) elementary_dilation_(const Binary_Image<I>& input)
+ {
+ return elementary_dilation_on_set_(exact(input), exact(input));
+ }
+
+ } // end of namespace oln::morpho::impl
+
+
+ // Facade.
+
+ template <typename I>
+ oln_plain(I)
+ elementary_dilation(const Image_with_Nbh<I>& input)
+ {
+ return impl::elementary_dilation_(exact(input));
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
+
+ } // end of namespace oln::morpho
+
+} // end of namespace oln
+
+
+#endif // ! OLN_MORPHO_ELEMENTARY_DILATION_HH
Index: oln/level/local.hh
--- oln/level/local.hh (revision 891)
+++ oln/level/local.hh (working copy)
@@ -45,9 +45,9 @@
const Image_with_Nbh<I>& input,
const oln_point(I)& p);
- template <typename F, typename I, typename W>
- typename F::result
- local(const Accumulator<F>& f,
+ template <typename A, typename I, typename W>
+ typename A::result
+ local(const Accumulator<A>& f,
const Image<I>& input,
const oln_point(I)& p,
const Window<W>& win);
@@ -79,9 +79,9 @@
// Generic version with window.
- template <typename F, typename I, typename W>
- typename F::result
- local_(const F& f,
+ template <typename A, typename I, typename W>
+ typename A::result
+ local_(const A& f,
const Image<I>& input,
const oln_point(I)& p,
const Window<W>& win)
@@ -107,9 +107,9 @@
return impl::local_(exact(f), input, p);
}
- template <typename F, typename I, typename W>
- typename F::result
- local(const Accumulator<F>& f,
+ template <typename A, typename I, typename W>
+ typename A::result
+ local(const Accumulator<A>& f,
const Image<I>& input,
const oln_point(I)& p,
const Window<W>& win)
Index: oln/value/default.hh
--- oln/value/default.hh (revision 891)
+++ oln/value/default.hh (working copy)
@@ -28,7 +28,7 @@
#ifndef OLN_VALUE_DEFAULT_HH
# define OLN_VALUE_DEFAULT_HH
-# include <oln/value/greylevel.hh>
+# include <oln/value/graylevel.hh>
namespace oln
@@ -38,16 +38,16 @@
{
/// White.
- extern const greylevel white;
+ extern const graylevel white;
/// Black.
- extern const greylevel black;
+ extern const graylevel black;
# ifndef OLN_INCLUDE_ONLY
- const greylevel white = greylevel(1, 1);
- const greylevel black = greylevel(1, 0);
+ const graylevel white = graylevel(1, 1);
+ const graylevel black = graylevel(1, 0);
# endif
Index: oln/value/all.hh
--- oln/value/all.hh (revision 891)
+++ oln/value/all.hh (working copy)
@@ -31,7 +31,7 @@
# include <oln/value/tags.hh>
-# include <oln/value/greylevel.hh>
+# include <oln/value/graylevel.hh>
# include <oln/value/bin.hh>
# include <oln/value/default.hh>
Index: oln/value/bin.hh
--- oln/value/bin.hh (revision 891)
+++ oln/value/bin.hh (working copy)
@@ -31,7 +31,7 @@
# include <mlc/bexpr.hh>
# include <xtd/optraits.hh>
# include <xtd/valtraits.hh>
-# include <oln/value/greylevel.hh>
+# include <oln/value/graylevel.hh>
namespace oln
@@ -40,7 +40,7 @@
namespace value
{
- typedef greylevel_<1> bin;
+ typedef graylevel_<1> bin;
// Binary ops.
Index: oln/value/graylevel.hh
--- oln/value/graylevel.hh (revision 891)
+++ oln/value/graylevel.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 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
@@ -25,8 +25,8 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_VALUE_GREYLEVEL_HH
-# define OLN_CORE_VALUE_GREYLEVEL_HH
+#ifndef OLN_CORE_VALUE_GRAYLEVEL_HH
+# define OLN_CORE_VALUE_GRAYLEVEL_HH
# include <iostream>
# include <mlc/contract.hh>
@@ -58,22 +58,22 @@
/// Fwd decl.
- class greylevel;
+ class graylevel;
- /// General grey-level class on n bits.
+ /// General gray-level class on n bits.
template <unsigned nbits>
- class greylevel_ : public oln::abstract::value
+ class graylevel_ : public oln::abstract::value
{
typedef typename internal::encoding<nbits>::ret encoding_t;
public:
/// Ctor.
- greylevel_();
+ graylevel_();
/// Ctor.
- explicit greylevel_(const typename internal::encoding<nbits>::ret& val);
+ explicit graylevel_(const typename internal::encoding<nbits>::ret& val);
/// Access to std type.
typename internal::encoding<nbits>::ret value() const;
@@ -81,14 +81,14 @@
/// Op encoding_t.
operator typename internal::encoding<nbits>::ret() const;
- /// Op greylevel.
- operator greylevel() const;
+ /// Op graylevel.
+ operator graylevel() const;
/// Op<.
- bool operator<(const greylevel_<nbits>& rhs) const;
+ bool operator<(const graylevel_<nbits>& rhs) const;
/// Op=.
- bool operator=(const greylevel_<nbits>& rhs) const;
+ bool operator=(const graylevel_<nbits>& rhs) const;
protected:
encoding_t val_;
@@ -97,50 +97,50 @@
/// Op<<.
template <unsigned nbits>
- std::ostream& operator<<(std::ostream& ostr, const
greylevel_<nbits>& g);
+ std::ostream& operator<<(std::ostream& ostr, const
graylevel_<nbits>& g);
/// Aliases.
- typedef greylevel_<8> gl8;
- typedef greylevel_<16> gl16;
- typedef greylevel_<32> gl32;
+ typedef graylevel_<8> gl8;
+ typedef graylevel_<16> gl16;
+ typedef graylevel_<32> gl32;
template <unsigned nbits, unsigned mbits>
- bool operator=(const greylevel_<nbits>& lhs, const
greylevel_<mbits>& rhs);
+ bool operator=(const graylevel_<nbits>& lhs, const
graylevel_<mbits>& rhs);
template <unsigned nbits, unsigned mbits>
- greylevel operator+(const greylevel_<nbits>& lhs, const
greylevel_<mbits>& rhs);
+ graylevel operator+(const graylevel_<nbits>& lhs, const
graylevel_<mbits>& rhs);
template <unsigned nbits, unsigned mbits>
- greylevel operator-(const greylevel_<nbits>& lhs, const
greylevel_<mbits>& rhs);
+ graylevel operator-(const graylevel_<nbits>& lhs, const
graylevel_<mbits>& rhs);
template <unsigned nbits>
- greylevel operator*(int s, const greylevel_<nbits>& rhs);
+ graylevel operator*(int s, const graylevel_<nbits>& rhs);
template <unsigned nbits>
- greylevel operator*(const greylevel_<nbits>& lhs, int s);
+ graylevel operator*(const graylevel_<nbits>& lhs, int s);
template <unsigned nbits>
- greylevel operator/(const greylevel_<nbits>& lhs, int s);
+ graylevel operator/(const graylevel_<nbits>& lhs, int s);
- /// General grey-level class where n bits is not know at compile-time.
- /// This class is used for exchange between grey-level types purpose.
- class greylevel : public oln::abstract::value
+ /// General gray-level class where n bits is not know at compile-time.
+ /// This class is used for exchange between gray-level types purpose.
+ class graylevel : public oln::abstract::value
{
public:
/// Ctor.
- greylevel();
+ graylevel();
/// Ctor.
template <unsigned n>
- greylevel(const greylevel_<n>& val);
+ graylevel(const graylevel_<n>& val);
/// Ctor.
- greylevel(unsigned nbits, unsigned long val);
+ graylevel(unsigned nbits, unsigned long val);
/// Access to std type.
unsigned long value() const;
@@ -149,14 +149,14 @@
void set_nbits(unsigned nbits);
- greylevel to_nbits(unsigned nbits) const;
+ graylevel to_nbits(unsigned nbits) const;
template <unsigned n>
- operator greylevel_<n>() const;
+ operator graylevel_<n>() const;
- bool operator<(const greylevel& rhs) const;
+ bool operator<(const graylevel& rhs) const;
- bool operator=(const greylevel& rhs) const;
+ bool operator=(const graylevel& rhs) const;
protected:
unsigned nbits_;
@@ -164,144 +164,144 @@
};
- std::ostream& operator<<(std::ostream& ostr, const greylevel& g);
+ std::ostream& operator<<(std::ostream& ostr, const graylevel& g);
- greylevel operator+(const greylevel& lhs, const greylevel& rhs);
- greylevel operator-(const greylevel& lhs, const greylevel& rhs);
+ graylevel operator+(const graylevel& lhs, const graylevel& rhs);
+ graylevel operator-(const graylevel& lhs, const graylevel& rhs);
- greylevel operator*(int s, const greylevel& rhs);
- greylevel operator*(const greylevel& lhs, int s);
+ graylevel operator*(int s, const graylevel& rhs);
+ graylevel operator*(const graylevel& lhs, int s);
- greylevel operator/(const greylevel& lhs, int s);
+ graylevel operator/(const graylevel& lhs, int s);
# ifndef OLN_INCLUDE_ONLY
- // Greylevel_<nbits>.
+ // Graylevel_<nbits>.
template <unsigned nbits>
- greylevel_<nbits>::greylevel_()
+ graylevel_<nbits>::graylevel_()
{
}
template <unsigned nbits>
- greylevel_<nbits>::greylevel_(const typename
internal::encoding<nbits>::ret& val)
+ graylevel_<nbits>::graylevel_(const typename
internal::encoding<nbits>::ret& val)
: val_(val)
{
}
template <unsigned nbits>
typename internal::encoding<nbits>::ret
- greylevel_<nbits>::value() const
+ graylevel_<nbits>::value() const
{
return val_;
}
template <unsigned nbits>
- greylevel_<nbits>::operator greylevel() const
+ graylevel_<nbits>::operator graylevel() const
{
- greylevel tmp(nbits, val_);
+ graylevel tmp(nbits, val_);
return tmp;
}
template <unsigned nbits>
- greylevel_<nbits>::operator typename internal::encoding<nbits>::ret()
const
+ graylevel_<nbits>::operator typename internal::encoding<nbits>::ret()
const
{
return val_;
}
template <unsigned nbits>
- bool greylevel_<nbits>::operator<(const greylevel_<nbits>& rhs)
const
+ bool graylevel_<nbits>::operator<(const graylevel_<nbits>& rhs)
const
{
return val_ < rhs.val_;
}
template <unsigned nbits>
- bool greylevel_<nbits>::operator=(const greylevel_<nbits>& rhs)
const
+ bool graylevel_<nbits>::operator=(const graylevel_<nbits>& rhs)
const
{
return val_ = rhs.val_;
}
template <unsigned nbits>
- std::ostream& operator<<(std::ostream& ostr, const
greylevel_<nbits>& g)
+ std::ostream& operator<<(std::ostream& ostr, const
graylevel_<nbits>& g)
{
return ostr << g.value();
}
template <unsigned nbits, unsigned mbits>
- bool operator=(const greylevel_<nbits>& lhs, const
greylevel_<mbits>& rhs)
+ bool operator=(const graylevel_<nbits>& lhs, const
graylevel_<mbits>& rhs)
{
- return greylevel(lhs) = greylevel(rhs);
+ return graylevel(lhs) = graylevel(rhs);
}
template <unsigned nbits, unsigned mbits>
- greylevel operator+(const greylevel_<nbits>& lhs, const
greylevel_<mbits>& rhs)
+ graylevel operator+(const graylevel_<nbits>& lhs, const
graylevel_<mbits>& rhs)
{
- return greylevel(lhs) + greylevel(rhs);
+ return graylevel(lhs) + graylevel(rhs);
}
template <unsigned nbits, unsigned mbits>
- greylevel operator-(const greylevel_<nbits>& lhs, const
greylevel_<mbits>& rhs)
+ graylevel operator-(const graylevel_<nbits>& lhs, const
graylevel_<mbits>& rhs)
{
- return greylevel(lhs) - greylevel(rhs);
+ return graylevel(lhs) - graylevel(rhs);
}
template <unsigned nbits>
- greylevel operator*(int s, const greylevel_<nbits>& rhs)
+ graylevel operator*(int s, const graylevel_<nbits>& rhs)
{
precondition(s >= 0);
- greylevel tmp(nbits, s * rhs.value());
+ graylevel tmp(nbits, s * rhs.value());
return tmp;
}
template <unsigned nbits>
- greylevel operator*(const greylevel_<nbits>& lhs, int s)
+ graylevel operator*(const graylevel_<nbits>& lhs, int s)
{
precondition(s >= 0);
- greylevel tmp(nbits, lhs.value() * s);
+ graylevel tmp(nbits, lhs.value() * s);
return tmp;
}
template <unsigned nbits>
- greylevel operator/(const greylevel_<nbits>& lhs, int s)
+ graylevel operator/(const graylevel_<nbits>& lhs, int s)
{
precondition(s > 0);
- greylevel tmp(nbits, lhs.value() / s);
+ graylevel tmp(nbits, lhs.value() / s);
return tmp;
}
- // Greylevel.
+ // Graylevel.
- greylevel::greylevel()
+ graylevel::graylevel()
: nbits_(0)
{
}
template <unsigned n>
- greylevel::greylevel(const greylevel_<n>& g)
+ graylevel::graylevel(const graylevel_<n>& g)
: nbits_(n),
val_(g.value())
{
}
- greylevel::greylevel(unsigned nbits, unsigned long val)
+ graylevel::graylevel(unsigned nbits, unsigned long val)
: nbits_(nbits),
val_(val)
{
}
- unsigned long greylevel::value() const
+ unsigned long graylevel::value() const
{
invariant(nbits_ != 0);
return val_;
}
- unsigned greylevel::nbits() const
+ unsigned graylevel::nbits() const
{
return nbits_;
}
@@ -337,7 +337,7 @@
} // end of oln::value::internal
- void greylevel::set_nbits(unsigned nbits)
+ void graylevel::set_nbits(unsigned nbits)
{
precondition(nbits != 0);
invariant(nbits_ != 0);
@@ -356,26 +356,26 @@
}
- greylevel greylevel::to_nbits(unsigned nbits) const
+ graylevel graylevel::to_nbits(unsigned nbits) const
{
precondition(nbits != 0);
invariant(nbits_ != 0);
- greylevel tmp(*this);
+ graylevel tmp(*this);
tmp.set_nbits(nbits);
return tmp;
}
template <unsigned n>
- greylevel::operator greylevel_<n>() const
+ graylevel::operator graylevel_<n>() const
{
precondition(nbits_ != 0);
- greylevel_<n> tmp(internal::convert<n>(nbits_, val_));
+ graylevel_<n> tmp(internal::convert<n>(nbits_, val_));
assert(tmp.value() < internal::two_pow_(n));
return tmp;
}
- bool greylevel::operator<(const greylevel& rhs) const
+ bool graylevel::operator<(const graylevel& rhs) const
{
precondition(nbits_ != 0 and rhs.nbits() != 0);
if (rhs.nbits() = nbits_)
@@ -386,7 +386,7 @@
return this->to_nbits(rhs.nbits()).value() < rhs.value();
}
- bool greylevel::operator=(const greylevel& rhs) const
+ bool graylevel::operator=(const graylevel& rhs) const
{
precondition(nbits_ != 0 and rhs.nbits() != 0);
if (rhs.nbits() = nbits_)
@@ -397,36 +397,36 @@
return this->to_nbits(rhs.nbits()).value() = rhs.value();
}
- std::ostream& operator<<(std::ostream& ostr, const greylevel& g)
+ std::ostream& operator<<(std::ostream& ostr, const graylevel& g)
{
return ostr << g.value() << '/' << g.nbits() <<
"nbits";
}
- greylevel operator+(const greylevel& lhs, const greylevel& rhs)
+ graylevel operator+(const graylevel& lhs, const graylevel& rhs)
{
precondition(lhs.nbits() != 0 and rhs.nbits() != 0);
if (lhs.nbits() > rhs.nbits())
{
- greylevel tmp(lhs.nbits(),
+ graylevel tmp(lhs.nbits(),
lhs.value() + rhs.to_nbits(lhs.nbits()).value());
return tmp;
}
else
{
- greylevel tmp(rhs.nbits(),
+ graylevel tmp(rhs.nbits(),
lhs.to_nbits(rhs.nbits()).value() + rhs.value());
return tmp;
}
}
- greylevel operator-(const greylevel& lhs, const greylevel& rhs)
+ graylevel operator-(const graylevel& lhs, const graylevel& rhs)
{
precondition(lhs.nbits() != 0 and rhs.nbits() != 0);
if (lhs.nbits() > rhs.nbits())
{
unsigned long l = rhs.to_nbits(lhs.nbits()).value();
assert(lhs.value() >= l);
- greylevel tmp(lhs.nbits(),
+ graylevel tmp(lhs.nbits(),
lhs.value() - l);
return tmp;
}
@@ -434,30 +434,30 @@
{
unsigned long l = lhs.to_nbits(rhs.nbits()).value();
assert(l >= rhs.value());
- greylevel tmp(rhs.nbits(),
+ graylevel tmp(rhs.nbits(),
l - rhs.value());
return tmp;
}
}
- greylevel operator*(int s, const greylevel& rhs)
+ graylevel operator*(int s, const graylevel& rhs)
{
precondition(s >= 0);
- greylevel tmp(rhs.nbits(), rhs.value() * s);
+ graylevel tmp(rhs.nbits(), rhs.value() * s);
return tmp;
}
- greylevel operator*(const greylevel& lhs, int s)
+ graylevel operator*(const graylevel& lhs, int s)
{
precondition(s >= 0);
- greylevel tmp(lhs.nbits(), lhs.value() * s);
+ graylevel tmp(lhs.nbits(), lhs.value() * s);
return tmp;
}
- greylevel operator/(const greylevel& lhs, int s)
+ graylevel operator/(const graylevel& lhs, int s)
{
precondition(s > 0);
- greylevel tmp(lhs.nbits(), lhs.value() / s);
+ graylevel tmp(lhs.nbits(), lhs.value() / s);
return tmp;
}
@@ -473,32 +473,32 @@
namespace xtd
{
- using oln::value::greylevel;
+ using oln::value::graylevel;
- template <> struct set_trait_<op_plus, greylevel, greylevel> { typedef
greylevel ret; };
- template <> struct set_trait_<op_minus, greylevel, greylevel> { typedef
greylevel ret; };
- template <> struct set_trait_<op_mult, int, greylevel> { typedef
greylevel ret; };
- template <> struct set_trait_<op_mult, greylevel, int > { typedef
greylevel ret; };
- template <> struct set_trait_<op_div, greylevel, int > { typedef
greylevel ret; };
+ template <> struct set_trait_<op_plus, graylevel, graylevel> { typedef
graylevel ret; };
+ template <> struct set_trait_<op_minus, graylevel, graylevel> { typedef
graylevel ret; };
+ template <> struct set_trait_<op_mult, int, graylevel> { typedef
graylevel ret; };
+ template <> struct set_trait_<op_mult, graylevel, int > { typedef
graylevel ret; };
+ template <> struct set_trait_<op_div, graylevel, int > { typedef
graylevel ret; };
- using oln::value::greylevel_;
+ using oln::value::graylevel_;
template <unsigned nbits, unsigned mbits>
- struct set_trait_< op_plus, greylevel_<nbits>, greylevel_<mbits> > {
typedef greylevel ret; };
+ struct set_trait_< op_plus, graylevel_<nbits>, graylevel_<mbits> > {
typedef graylevel ret; };
template <unsigned nbits, unsigned mbits>
- struct set_trait_< op_minus, greylevel_<nbits>, greylevel_<mbits> > {
typedef greylevel ret; };
+ struct set_trait_< op_minus, graylevel_<nbits>, graylevel_<mbits> > {
typedef graylevel ret; };
template <unsigned nbits>
- struct set_trait_< op_mult, int, greylevel_<nbits> > { typedef greylevel
ret; };
+ struct set_trait_< op_mult, int, graylevel_<nbits> > { typedef graylevel
ret; };
template <unsigned nbits>
- struct set_trait_< op_mult, greylevel_<nbits>, int > { typedef greylevel
ret; };
+ struct set_trait_< op_mult, graylevel_<nbits>, int > { typedef graylevel
ret; };
template <unsigned nbits>
- struct set_trait_< op_div, greylevel_<nbits>, int > { typedef greylevel
ret; };
+ struct set_trait_< op_div, graylevel_<nbits>, int > { typedef graylevel
ret; };
} // end of namespace xtd
-#endif // ! OLN_CORE_VALUE_GREYLEVEL_HH
+#endif // ! OLN_CORE_VALUE_GRAYLEVEL_HH
Index: oln/value/tags.hh
--- oln/value/tags.hh (revision 891)
+++ oln/value/tags.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 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
@@ -28,6 +28,7 @@
#ifndef OLN_VALUE_TAGS_HH
# define OLN_VALUE_TAGS_HH
+# include <string>
# include <mlc/bexpr.hh>
@@ -55,22 +56,22 @@
struct is_color < color::rgb_<T> > : public mlc::bexpr_<true> {};
- // Grey-level trait.
+ // Gray-level trait.
template <typename T>
- struct is_grey_level : public mlc::bexpr_<false>
+ struct is_gray_level : public mlc::bexpr_<false>
{};
template <unsigned nbits>
- class greylevel_;
+ class graylevel_;
template <unsigned nbits>
- struct is_grey_level < greylevel_<nbits> > : public
mlc::bexpr_<true> {};
+ struct is_gray_level < graylevel_<nbits> > : public
mlc::bexpr_<true> {};
- class greylevel;
+ class graylevel;
template <>
- struct is_grey_level < greylevel > : public mlc::bexpr_<true> {};
+ struct is_gray_level < graylevel > : public mlc::bexpr_<true> {};
// Binary trait.
@@ -83,16 +84,27 @@
template <>
struct is_binary < bool > : public mlc::bexpr_<true> {};
- typedef greylevel_<1> bin;
+ typedef graylevel_<1> bin;
template <>
struct is_binary < bin > : public mlc::bexpr_<true> {};
+ // String trait.
+
+ template <typename T>
+ struct is_string : public mlc::bexpr_<false>
+ {
+ };
+
+ template <>
+ struct is_string < std::string > : public mlc::bexpr_<true> {};
+
+
// Label trait.
template <typename T>
- struct is_label : public mlc::bexpr_<false>
+ struct is_label : public mlc::or_< is_binary<T>, is_string<T> >
{
};