URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2008-02-13 Michel Pellegrin <pellegrin(a)lrde.epita.fr>
Commit of personnal work in my sandbox.
* sandbox/pellegrin/Makefile: New.
* sandbox/pellegrin/first_test.cc: New.
* sandbox/pellegrin/set/Makefile: New.
* sandbox/pellegrin/set/multi_set.hh: New.
* sandbox/pellegrin/set/test_set.cc: New.
* sandbox/pellegrin/set/uni_set.hh: New.
* sandbox/pellegrin/set: New.
---
Makefile | 26 ++++++++
first_test.cc | 40 ++++++++++++
set/Makefile | 26 ++++++++
set/multi_set.hh | 176 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
set/test_set.cc | 47 ++++++++++++++
set/uni_set.hh | 176 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 491 insertions(+)
Index: trunk/milena/sandbox/pellegrin/first_test.cc
===================================================================
--- trunk/milena/sandbox/pellegrin/first_test.cc (revision 0)
+++ trunk/milena/sandbox/pellegrin/first_test.cc (revision 1721)
@@ -0,0 +1,40 @@
+// 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.
+
+/*! \file sandbox/pellegrin/first_test.cc
+ *
+ * \brief My first test.
+ */
+
+#include <mln/core/image2d.hh>
+
+
+int main ()
+{
+ mln::image2d<int> I;
+}
+
Index: trunk/milena/sandbox/pellegrin/set/multi_set.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/multi_set.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/multi_set.hh (revision 1721)
@@ -0,0 +1,176 @@
+// 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 __MULTI_SET_HH__
+# define __MULTI_SET_HH__
+
+/*! \file sandbox/pellegrin/set/multi_set.hh
+ *
+ * \brief Definition of a point multi-set class.
+ */
+
+# include <mln/core/internal/point_set_base.hh>
+# include <mln/core/internal/set_of.hh>
+
+
+namespace mln
+{
+
+ /*! \brief Point set class.
+ *
+ * This is a mathematical multi-set of points. The
+ * parameter \p P shall be a Point type.
+ *
+ * \todo All.
+ */
+ template <typename P>
+ class multi_set : public internal::point_set_base_< P, p_set<P> >,
+ private internal::set_of_<P>
+ {
+ typedef internal::set_of_<P> super_;
+
+ public:
+ /// Forward Point_Iterator associated type.
+ typedef multi_set_fwd_piter_<P> fwd_piter;
+ /// Backward Point_Iterator associated type.
+ typedef multi_set_bkd_piter_<P> bkd_piter;
+
+ /// Constructor.
+ multi_set();
+
+ /// Test is \p p belongs to this point set.
+ bool has(const P& p) const;
+
+ /// Return the corresponding std::vector of points.
+ using super_::vect;
+
+ /// Give the number of points.
+ std::size_t npoints() const;
+
+ /// Insert a point \p p.
+ multi_set<P>& insert(const P& p);
+
+ // FIXME : doesn't compile
+ // /// Remove a point \p p.
+ // p_set<P>& remove(P& p);
+
+ /// Return the \p i-th point.
+ const P& operator[](unsigned i) const;
+
+ /// Clear this set.
+ void clear();
+
+ /// Give the exact bounding box.
+ const box_<mln_point(P)>& bbox() const;
+
+ protected:
+
+ accu::bbox<P> bb_;
+ // FIXME: Add invariant bb_.is_valid() <=> npoints() != 0
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P>
+ inline
+ multi_set<P>::multi_set()
+ {
+ }
+
+ template <typename P>
+ inline
+ bool
+ multi_set<P>::has(const P& p) const
+ {
+ return this->super_::has(p);
+ }
+
+ template <typename P>
+ inline
+ std::size_t
+ multi_set<P>::npoints() const
+ {
+ return this->super_::nelements();
+ }
+
+ template <typename P>
+ inline
+ multi_set<P>&
+ multi_set<P>::insert(const P& p)
+ {
+ this->super_::insert(p);
+ bb_.take(p);
+ return *this;
+ }
+
+
+ // FIXME : finish it.
+ // template <typename P>
+ // p_set<P>&
+ // p_set<P>::remove(P& p)
+ // {
+ // this->super_::remove(p);
+ // // FIXME: need to rebuild bb_ ?
+ // //bb_.untake(p);
+ // return *this;
+ // }
+
+ template <typename P>
+ inline
+ const P&
+ multi_set<P>::operator[](unsigned i) const
+ {
+ mln_precondition(i < npoints());
+ return this->super_::element(i);
+ }
+
+ template <typename P>
+ inline
+ void
+ multi_set<P>::clear()
+ {
+ this->super_::clear();
+ bb_.init();
+ }
+
+ template <typename P>
+ inline
+ const box_<mln_point(P)>&
+ multi_set<P>::bbox() const
+ {
+ mln_precondition(npoints() != 0);
+ return bb_.to_result();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! __MULTI_SET_HH__
Index: trunk/milena/sandbox/pellegrin/set/uni_set.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/uni_set.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/uni_set.hh (revision 1721)
@@ -0,0 +1,176 @@
+// 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 __UNI_SET_HH__
+# define __UNI_SET_HH__
+
+/*! \file sandbox/pellegrin/set/uni_set.hh
+ *
+ * \brief Definition of a point uni-set class.
+ */
+
+# include <mln/core/internal/point_set_base.hh>
+# include <mln/core/internal/set_of.hh>
+
+
+namespace mln
+{
+
+ /*! \brief Point set class.
+ *
+ * This is a mathematical uni-set of points (not a multi-set). The
+ * parameter \p P shall be a Point type.
+ *
+ * \todo All.
+ */
+ template <typename P>
+ class uni_set : public internal::point_set_base_< P, p_set<P> >,
+ private internal::set_of_<P>
+ {
+ typedef internal::set_of_<P> super_;
+
+ public:
+ /// Forward Point_Iterator associated type.
+ typedef uni_set_fwd_piter_<P> fwd_piter;
+ /// Backward Point_Iterator associated type.
+ typedef uni_set_bkd_piter_<P> bkd_piter;
+
+ /// Constructor.
+ uni_set();
+
+ /// Test is \p p belongs to this point set.
+ bool has(const P& p) const;
+
+ /// Return the corresponding std::vector of points.
+ using super_::vect;
+
+ /// Give the number of points.
+ std::size_t npoints() const;
+
+ /// Insert a point \p p.
+ uni_set<P>& insert(const P& p);
+
+ // FIXME : doesn't compile
+ // /// Remove a point \p p.
+ // p_set<P>& remove(P& p);
+
+ /// Return the \p i-th point.
+ const P& operator[](unsigned i) const;
+
+ /// Clear this set.
+ void clear();
+
+ /// Give the exact bounding box.
+ const box_<mln_point(P)>& bbox() const;
+
+ protected:
+
+ accu::bbox<P> bb_;
+ // FIXME: Add invariant bb_.is_valid() <=> npoints() != 0
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P>
+ inline
+ uni_set<P>::uni_set()
+ {
+ }
+
+ template <typename P>
+ inline
+ bool
+ uni_set<P>::has(const P& p) const
+ {
+ return this->super_::has(p);
+ }
+
+ template <typename P>
+ inline
+ std::size_t
+ uni_set<P>::npoints() const
+ {
+ return this->super_::nelements();
+ }
+
+ template <typename P>
+ inline
+ uni_set<P>&
+ uni_set<P>::insert(const P& p)
+ {
+ this->super_::insert(p);
+ bb_.take(p);
+ return *this;
+ }
+
+
+ // FIXME : finish it.
+ // template <typename P>
+ // p_set<P>&
+ // p_set<P>::remove(P& p)
+ // {
+ // this->super_::remove(p);
+ // // FIXME: need to rebuild bb_ ?
+ // //bb_.untake(p);
+ // return *this;
+ // }
+
+ template <typename P>
+ inline
+ const P&
+ uni_set<P>::operator[](unsigned i) const
+ {
+ mln_precondition(i < npoints());
+ return this->super_::element(i);
+ }
+
+ template <typename P>
+ inline
+ void
+ uni_set<P>::clear()
+ {
+ this->super_::clear();
+ bb_.init();
+ }
+
+ template <typename P>
+ inline
+ const box_<mln_point(P)>&
+ uni_set<P>::bbox() const
+ {
+ mln_precondition(npoints() != 0);
+ return bb_.to_result();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! __UNI_SET_HH__
Index: trunk/milena/sandbox/pellegrin/set/Makefile
===================================================================
--- trunk/milena/sandbox/pellegrin/set/Makefile (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/Makefile (revision 1721)
@@ -0,0 +1,26 @@
+All_warnings = -ansi -pedantic -Wabi -Wctor-dtor-privacy -Wnon-virtual-dtor \
+ -Wreorder -Weffc++ -Wno-deprecated -Wstrict-null-sentinel \
+ -Wno-non-template-friend -Wold-style-cast -Woverloaded-virtual \
+ -Wno-pmf-conversions -Wsign-promo -fsyntax-only-pedantic-errors \
+ -w -Wextra -Wall -Waddress -Waggregate-return -Wno-attributes \
+ -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment -Wconversion \
+ -Wno-deprecated-declarations -Wdisabled-optimization -Wno-div-by-zero \
+ -Wno-endif-labels -Werror -Wfatal-errors -Wfloat-equal -Wformat \
+ -Wformat=2 -Wno-format-extra-args -Wformat-nonliteral \
+ -Wformat-security -Wformat-y2k -Wimplicit -Wimport -Wno-import \
+ -Winit-self -Winline -Wno-invalid-offsetof -Winvalid-pch \
+ -Wlarger-than-1 -Wunsafe-loop-optimizations -Wlong-long \
+ -Wmissing-braces -Wmissing-field-initializers \
+ -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn \
+ -Wno-multichar -Wno-overflow -Woverlength-strings -Wpacked -Wpadded \
+ -Wparentheses -Wpointer-arith -Wredundant-decls -Wreturn-type \
+ -Wsequence-point -Wshadow -Wsign-compare -Wstack-protector \
+ -Wstrict-aliasing -Wstrict-overflow -Wswitch -Wswitch-default \
+ -Wswitch-enum -Wsystem-headers -Wtrigraphs -Wundef -Wuninitialized \
+ -Wunknown-pragmas -Wno-pragmas -Wunreachable-code -Wunused \
+ -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value \
+ -Wunused-variable -Wvariadic-macros -Wvolatile-register-var \
+ -Wwrite-strings \
+
+all:
+ g++-4.2 -ansi -pedantic -I../.. first_test.cc -o first_test
Index: trunk/milena/sandbox/pellegrin/set/test_set.cc
===================================================================
--- trunk/milena/sandbox/pellegrin/set/test_set.cc (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/test_set.cc (revision 1721)
@@ -0,0 +1,47 @@
+// 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.
+
+/*! \file sandbox/pellegrin/set/test_set.cc
+ *
+ * \brief test my work on set.
+ */
+
+#include <mln/core/image2d.hh>
+#include "uni_set.hh"
+#include "multi_set.hh"
+
+
+int main ()
+{
+ mln::image2d<value::int_u8> I = io::pgm::load ("../img/lena.pgm");
+ mln::image2d<value::int_u8>::fwd_piter p (I.domain ());
+
+ for_all (p)
+ {
+ }
+}
+
Index: trunk/milena/sandbox/pellegrin/Makefile
===================================================================
--- trunk/milena/sandbox/pellegrin/Makefile (revision 0)
+++ trunk/milena/sandbox/pellegrin/Makefile (revision 1721)
@@ -0,0 +1,26 @@
+All_warnings = -ansi -pedantic -Wabi -Wctor-dtor-privacy -Wnon-virtual-dtor \
+ -Wreorder -Weffc++ -Wno-deprecated -Wstrict-null-sentinel \
+ -Wno-non-template-friend -Wold-style-cast -Woverloaded-virtual \
+ -Wno-pmf-conversions -Wsign-promo -fsyntax-only-pedantic-errors \
+ -w -Wextra -Wall -Waddress -Waggregate-return -Wno-attributes \
+ -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment -Wconversion \
+ -Wno-deprecated-declarations -Wdisabled-optimization -Wno-div-by-zero \
+ -Wno-endif-labels -Werror -Wfatal-errors -Wfloat-equal -Wformat \
+ -Wformat=2 -Wno-format-extra-args -Wformat-nonliteral \
+ -Wformat-security -Wformat-y2k -Wimplicit -Wimport -Wno-import \
+ -Winit-self -Winline -Wno-invalid-offsetof -Winvalid-pch \
+ -Wlarger-than-1 -Wunsafe-loop-optimizations -Wlong-long \
+ -Wmissing-braces -Wmissing-field-initializers \
+ -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn \
+ -Wno-multichar -Wno-overflow -Woverlength-strings -Wpacked -Wpadded \
+ -Wparentheses -Wpointer-arith -Wredundant-decls -Wreturn-type \
+ -Wsequence-point -Wshadow -Wsign-compare -Wstack-protector \
+ -Wstrict-aliasing -Wstrict-overflow -Wswitch -Wswitch-default \
+ -Wswitch-enum -Wsystem-headers -Wtrigraphs -Wundef -Wuninitialized \
+ -Wunknown-pragmas -Wno-pragmas -Wunreachable-code -Wunused \
+ -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value \
+ -Wunused-variable -Wvariadic-macros -Wvolatile-register-var \
+ -Wwrite-strings \
+
+all:
+ g++-4.2 -ansi -pedantic -I../.. first_test.cc -o first_test
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2008-02-13 Michel Pellegrin <pellegrin(a)lrde.epita.fr>
Fix Doxygen comment.
* mln/core/internal/set_of.hh: here.
---
set_of.hh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Index: trunk/milena/mln/core/internal/set_of.hh
===================================================================
--- trunk/milena/mln/core/internal/set_of.hh (revision 1719)
+++ trunk/milena/mln/core/internal/set_of.hh (revision 1720)
@@ -76,9 +76,9 @@
/*! \brief Remove an element \p elt into the set.
*
- * \param[in] elt The element to be inserted.
+ * \param[in] elt The element to be deleted.
*
- * If \p elt is already in the set, this method is a no-op.
+ * If \p elt is not in the set, this method is a no-op.
*
* \return The set itself after suppression.
*/
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2008-02-05 Caroline Vigouroux <vigour_c(a)epita.fr>
Added personal folder and color files in sandbox.
* sandbox/vigouroux/color.hh: New.
* sandbox/vigouroux/color/color.hh: New.
* sandbox/vigouroux/color/hsi.hh: New.
* sandbox/vigouroux/color/hsl.hh: New.
* sandbox/vigouroux/color/hsv.hh: New.
* sandbox/vigouroux/color/nrgb.hh: New.
* sandbox/vigouroux/color/rgb.hh: New.
* sandbox/vigouroux/color/xyz.hh: New.
* sandbox/vigouroux/color/yiq.hh: New.
* sandbox/vigouroux/color/yuv.hh: New.
* sandbox/vigouroux/color: New.
* sandbox/vigouroux/convert/abstract/colorconv.hh: New.
* sandbox/vigouroux/convert/abstract/conversion.hh: New.
* sandbox/vigouroux/convert/abstract: New.
* sandbox/vigouroux/convert/basics.hh: New.
* sandbox/vigouroux/convert/bound.hh: New.
* sandbox/vigouroux/convert/cast.hh: New.
* sandbox/vigouroux/convert/conversion.hh: New.
* sandbox/vigouroux/convert/conversion_ng_se.hh: New.
* sandbox/vigouroux/convert/force.hh: New.
* sandbox/vigouroux/convert/nrgbxyz.hh: New.
* sandbox/vigouroux/convert/rgbhsi.hh: New.
* sandbox/vigouroux/convert/rgbhsl.hh: New.
* sandbox/vigouroux/convert/rgbhsv.hh: New.
* sandbox/vigouroux/convert/rgbnrgb.hh: New.
* sandbox/vigouroux/convert/rgbxyz.hh: New.
* sandbox/vigouroux/convert/rgbyiq.hh: New.
* sandbox/vigouroux/convert/rgbyuv.hh: New.
* sandbox/vigouroux/convert/stretch.hh: New.
* sandbox/vigouroux/convert/value_to_point.hh: New.
* sandbox/vigouroux/convert: New folder.
* sandbox/vigouroux: New folder.
---
color.hh | 44 +++++
color/color.hh | 308 +++++++++++++++++++++++++++++++++++++++++
color/hsi.hh | 63 ++++++++
color/hsl.hh | 54 +++++++
color/hsv.hh | 55 +++++++
color/nrgb.hh | 130 +++++++++++++++++
color/rgb.hh | 58 +++++++
color/xyz.hh | 54 +++++++
color/yiq.hh | 64 ++++++++
color/yuv.hh | 63 ++++++++
convert/abstract/colorconv.hh | 68 +++++++++
convert/abstract/conversion.hh | 177 +++++++++++++++++++++++
convert/basics.hh | 38 +++++
convert/bound.hh | 66 ++++++++
convert/cast.hh | 63 ++++++++
convert/conversion.hh | 159 +++++++++++++++++++++
convert/conversion_ng_se.hh | 82 ++++++++++
convert/force.hh | 62 ++++++++
convert/nrgbxyz.hh | 181 ++++++++++++++++++++++++
convert/rgbhsi.hh | 153 ++++++++++++++++++++
convert/rgbhsl.hh | 226 ++++++++++++++++++++++++++++++
convert/rgbhsv.hh | 204 +++++++++++++++++++++++++++
convert/rgbnrgb.hh | 145 +++++++++++++++++++
convert/rgbxyz.hh | 143 +++++++++++++++++++
convert/rgbyiq.hh | 141 ++++++++++++++++++
convert/rgbyuv.hh | 139 ++++++++++++++++++
convert/stretch.hh | 217 ++++++++++++++++++++++++++++
convert/value_to_point.hh | 131 +++++++++++++++++
28 files changed, 3288 insertions(+)
Index: trunk/milena/sandbox/vigouroux/convert/rgbhsl.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/convert/rgbhsl.hh (revision 0)
+++ trunk/milena/sandbox/vigouroux/convert/rgbhsl.hh (revision 1707)
@@ -0,0 +1,226 @@
+// Copyright (C) 2001, 2002, 2003, 2004 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, 59 Temple Place - Suite 330, 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 OLENA_CONVERT_NRGBHSL_HH
+# define OLENA_CONVERT_NRGBHSL_HH
+
+# include <oln/basics.hh>
+# include <oln/convert/abstract/colorconv.hh>
+
+# include <ntg/basics.hh>
+# include <ntg/color/nrgb.hh>
+# include <ntg/color/hsl.hh>
+
+# include <mlc/contract.hh>
+
+# include <cstdlib>
+# include <sstream>
+
+/*! \file olena/oln/convert/rgbhsl.hh
+**
+** REF: The formulas used here come from ``Color space conversion''; Paul
+** Bourke.
+*/
+namespace oln {
+
+ using namespace ntg;
+
+ namespace convert {
+ /*! Functor for conversion from RGB to HSL color space.
+ **
+ ** \note Every conversion should go though the RGB color space.
+ **
+ ** \code
+ ** #include <oln/basics2d.hh>
+ ** #include <oln/convert/rgbhsl.hh>
+ ** #include <ntg/all.hh>
+ **
+ ** int main()
+ ** {
+ ** oln::image2d<ntg::rgb_8> lena_rgb = oln::load(IMG_IN "lena.ppm");
+ **
+ ** oln::image2d<ntg::hsl_8> lena_hsl = apply(oln::convert::f_rgb_to_hsl<8, 8>(), lena_rgb);
+ ** oln::image2d<ntg::hsl_8>::iter_type it(lena_hsl);
+ ** for_all(it)
+ ** lena_hsl[it][ntg::hsl_L] = 127;
+ **
+ ** oln::io::save(apply(oln::convert::f_hsl_to_rgb<8, 8>(), lena_hsl),
+ ** IMG_OUT "oln_convert_f_rgb_to_hsl.pgm");
+ ** }
+ ** \endcode
+ ** \image html lena_ppm.png
+ ** \image latex lena_ppm.png
+ ** =>
+ ** \image html oln_convert_f_rgb_to_hsl.png
+ ** \image latex oln_convert_f_rgb_to_hsl.png
+ */
+ template<unsigned inbits, unsigned outbits>
+ struct f_rgb_to_hsl
+ : public abstract::color_conversion<3, inbits, rgb_traits,
+ 3, outbits, hsl_traits, f_rgb_to_hsl<inbits, outbits> >
+ {
+ color<3, outbits, hsl_traits>
+ doit(const color<3, inbits, rgb_traits>& v) const
+ {
+ vec<3, float> in = v.to_float();
+ vec<3, float> out;
+
+ float max_in = ntg::max(in[rgb_R], std::max(in[rgb_B], in[rgb_G]));
+ float min_in = ntg::min(in[rgb_R], std::min(in[rgb_B], in[rgb_G]));
+ float diff = max_in-min_in;
+
+ out[hsl_L] = (max_in + min_in) / 2;
+ if (std::abs(diff) <= FLT_EPSILON){
+ out[hsl_S] = 0;
+ out[hsl_H] = 0; // undefined
+ }
+ else {
+ if (out[hsl_L] <= 0.5)
+ out[hsl_S] = diff / (max_in + min_in);
+ else
+ out[hsl_S] = diff / (2 - max_in - min_in);
+
+
+ float r_dist = (max_in - in[rgb_R]) / diff;
+ float g_dist = (max_in - in[rgb_G]) / diff;
+ float b_dist = (max_in - in[rgb_B]) / diff;
+
+ if (in[rgb_R] == max_in)
+ out[hsl_H] = b_dist - g_dist;
+ else if(in[rgb_G] == max_in)
+ out[hsl_H] = 2 + r_dist - b_dist;
+ else if(in[rgb_B] == max_in)
+ out[hsl_H] = 4 + g_dist - r_dist;
+
+ out[hsl_H] *= 60;
+ if(out[hsl_H] < 0)
+ out[hsl_H] += 360;
+ }
+ return out;
+ }
+
+ static std::string
+ name()
+ {
+ std::ostringstream s;
+ s << "f_rgb_to_hsl<" << inbits << ", " << outbits << '>';
+ s.str();
+ }
+ };
+
+ /*! Conversion from RGB to HSL color space.
+ **
+ ** \see f_rgb_to_hsl
+ */
+ template <unsigned inbits, unsigned outbits>
+ color<3, inbits, hsl_traits>
+ rgb_to_hsl(const color<3, outbits, rgb_traits>& v)
+ {
+ f_rgb_to_hsl<inbits, outbits> f;
+ return f(v);
+ }
+
+ namespace internal {
+ float
+ RGB(float q1, float q2, float hue)
+ {
+ if (hue >= 360)
+ hue -= 360;
+ if (hue < 0)
+ hue += 360;
+ if (hue < 60)
+ return q1 + (q2 - q1) * hue / 60;
+ else if (hue < 180)
+ return q2;
+ else if (hue < 240)
+ return q1 + (q2 - q1) * (240 - hue) / 60;
+ else
+ return q1;
+ }
+ }
+
+ /*! Functor for conversion from HSL to RGB color space.
+ **
+ ** \see f_rgb_to_hsl
+ */
+ template<unsigned inbits, unsigned outbits>
+ struct f_hsl_to_rgb
+ : public abstract::color_conversion<3, inbits, hsl_traits,
+ 3, outbits, rgb_traits, f_hsl_to_rgb<inbits, outbits> >
+ {
+ color<3, outbits, rgb_traits>
+ doit(const color<3, inbits, hsl_traits>& v) const
+ {
+ vec<3, float> in = v.to_float();
+ vec<3, float> out;
+ float p2;
+
+ if(in[hsl_L] < 0.5)
+ p2 = in[hsl_L] * (1+in[hsl_S]);
+ else
+ p2 = in[hsl_L] + in[hsl_S] - (in[hsl_L] * in[hsl_S]);
+
+ float p1 = 2 * in[hsl_L] - p2;
+
+ if(in[hsl_S] == 0)
+ out[rgb_R] = out[rgb_G] = out[rgb_B] = in[hsl_L];
+ else
+ {
+ out[rgb_R] = internal::RGB(p1, p2, in[hsl_H] + 120);
+ out[rgb_G] = internal::RGB(p1, p2, in[hsl_H]);
+ out[rgb_B] = internal::RGB(p1, p2, in[hsl_H] - 120);
+ }
+
+ return out;
+ }
+
+ static std::string
+ name()
+ {
+ std::ostringstream s;
+ s << "f_hsl_to_rgb<" << inbits << ", " << outbits << '>';
+ s.str();
+ }
+ };
+
+ /*! Conversion from HSL to RGB color space.
+ **
+ ** \see f_rgb_to_hsl
+ */
+ template<unsigned inbits, unsigned outbits>
+ color<3, outbits, rgb_traits>
+ hsl_to_rgb(const color<3, inbits, hsl_traits>& v)
+ {
+ f_hsl_to_rgb<inbits, outbits> f;
+ return f(v);
+ }
+
+ } // convert
+} // oln
+
+#endif // OLENA_CONVERT_RGBHSL_HH
Index: trunk/milena/sandbox/vigouroux/convert/rgbnrgb.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/convert/rgbnrgb.hh (revision 0)
+++ trunk/milena/sandbox/vigouroux/convert/rgbnrgb.hh (revision 1707)
@@ -0,0 +1,145 @@
+// Copyright (C) 2001, 2002, 2003, 2004 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, 59 Temple Place - Suite 330, 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 OLENA_CONVERT_RGBNRGB_HH
+# define OLENA_CONVERT_RGBNRGB_HH
+
+# include <oln/convert/abstract/colorconv.hh>
+
+# include <ntg/color/rgb.hh>
+# include <ntg/color/nrgb.hh>
+# include <ntg/basics.hh>
+
+# include <sstream>
+
+/*! \file olena/oln/convert/rgbnrgb.hh
+**
+** REF: The formulas used here come from ``Digital Image Processing
+** Algorithms and Applications'', I. Pitas; Wiley-Interscience.
+*/
+
+namespace oln {
+
+ using namespace ntg;
+
+ namespace convert {
+
+ /*! Functor for conversion from RGB to N-RGB.
+ **
+ ** \see f_rgb_to_hsl
+ */
+ template<unsigned inbits, unsigned outbits>
+ struct f_rgb_to_nrgb
+ : public abstract::color_conversion<3, inbits, rgb_traits,
+ 3, outbits, nrgb_traits, f_rgb_to_nrgb<inbits, outbits> >
+ {
+ color<3, outbits, nrgb_traits>
+ doit(const color<3, inbits, rgb_traits>& v) const
+ {
+ vec<3, float> in = v.to_float();
+ vec<3, float> out;
+ out[nrgb_R] =
+ + 0.8417270*in[rgb_R] + 0.1560987*in[rgb_G] + 0.0906747*in[rgb_B];
+ out[nrgb_G] =
+ - 0.1290152*in[rgb_R] + 1.3189264*in[rgb_G] - 0.2031832*in[rgb_B];
+ out[nrgb_B] =
+ + 0.0074943*in[rgb_R] - 0.0688480*in[rgb_G] + 0.8972327*in[rgb_B];
+ return out;
+ }
+
+ static std::string
+ name()
+ {
+ std::ostringstream s;
+ s << "f_rgb_to_nrgb<" << inbits << ", " << outbits << '>';
+ s.str();
+ }
+ };
+
+ /*! Conversion from RGB to N-RGB.
+ **
+ ** \see f_rgb_to_hsl
+ */
+ template <unsigned inbits, unsigned outbits>
+ color<3, outbits, nrgb_traits>
+ rgb_to_nrgb(const color<3, inbits, rgb_traits>& v)
+ {
+ f_rgb_to_nrgb<inbits, outbits> f;
+
+ return f(v);
+ }
+
+ /*! Functor for conversion from N-RGB to RGB.
+ **
+ ** \see f_rgb_to_hsl
+ */
+ template <unsigned inbits, unsigned outbits>
+ struct f_nrgb_to_rgb
+ : public abstract::color_conversion<3, inbits, nrgb_traits,
+ 3, outbits, rgb_traits, f_nrgb_to_rgb<inbits, outbits> >
+ {
+ color<3, outbits, rgb_traits>
+ doit(const color<3, inbits, nrgb_traits>& v) const
+ {
+ vec<3, float> in = v.to_float();
+ vec<3, float> out;
+ out[rgb_R] =
+ + 1.167 * in[nrgb_R] - 0.146 * in[nrgb_G] - 0.151 * in[nrgb_B];
+ out[rgb_G] =
+ + 0.114 * in[nrgb_R] + 0.753 * in[nrgb_G] + 0.159 * in[nrgb_B];
+ out[rgb_B] =
+ - 0.001 * in[nrgb_R] + 0.059 * in[nrgb_G] + 1.128 * in[nrgb_B];
+ return out;
+ }
+
+ static std::string
+ name()
+ {
+ std::ostringstream s;
+ s << "f_nrgb_to_rgb<" << inbits << ", " << outbits << '>';
+ s.str();
+ }
+ };
+
+ /*! Conversion from N-RGB to RGB.
+ **
+ ** \see f_rgb_to_hsl
+ */
+ template <unsigned inbits, unsigned outbits>
+ color<3, outbits, rgb_traits>
+ nrgb_to_rgb(const color<3, inbits, nrgb_traits>& v)
+ {
+ f_nrgb_to_rgb<inbits, outbits> f;
+
+ return f(v);
+ }
+
+ } // convert
+} // oln
+
+#endif // OLENA_CONVERT_RGBNRGB_HH
Index: trunk/milena/sandbox/vigouroux/convert/conversion.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/convert/conversion.hh (revision 0)
+++ trunk/milena/sandbox/vigouroux/convert/conversion.hh (revision 1707)
@@ -0,0 +1,159 @@
+// Copyright (C) 2001, 2002, 2003, 2004 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, 59 Temple Place - Suite 330, 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 OLENA_CONVERT_CONVERSION_HH
+# define OLENA_CONVERT_CONVERSION_HH
+
+# include <mlc/type.hh>
+# include <oln/core/image.hh>
+# include <oln/core/compose.hh>
+# include <ntg/utils/debug.hh>
+# include <oln/convert/abstract/conversion.hh>
+# include <functional>
+
+namespace oln {
+ /*!
+ ** \brief Conversion implementation (for example cast, color, or
+ ** neighborhood to window).
+ */
+ namespace convert {
+
+ /*! Trait that returns the output of a conversion.
+ **
+ ** convoutput queries the output type of conversion ConvType for
+ ** an input of type InputType. This comes handy when computing
+ ** the return type of a function which takes a conversion function
+ ** in argument.
+ **
+ ** \note convoutput is exported in the namespace oln for convenience.
+ */
+ template<class ConvType, class Base, class InputType>
+ struct convoutput
+ {
+ typedef typename abstract::conversion<ConvType, Base>::template output<InputType>::ret ret;
+ };
+
+ /// \brief Internal purpose only.
+ namespace internal {
+ /*! Compose a conversion C and an adaptable unary function UF,
+ ** producing an adaptable unary function.
+ */
+ template <class C, class UF>
+ struct compconv1_ :
+ public std::unary_function <typename UF::argument_type,
+ typename C::template output<typename UF::argument_type>::ret>
+ {
+ typedef compconv1_ self_type;
+
+ typename self_type::result_type
+ operator()(typename self_type::argument_type arg) const
+ {
+ return conv_(func_(arg));
+ }
+
+ compconv1_(const C& conv, const UF& func)
+ : conv_(conv), func_(func)
+ {}
+ private:
+ const C conv_;
+ const UF func_;
+ };
+
+ /*! Compose a conversion C and an adaptable binary function BF,
+ ** producing an adaptable binary function.
+ */
+ template <class C, class BF>
+ struct compconv2_ :
+ public std::binary_function <typename BF::first_argument_type,
+ typename BF::second_argument_type,
+ typename C::template output<typename BF::result_type>::ret>
+ {
+ typedef compconv2_ self_type;
+
+ typename self_type::result_type
+ operator()(typename self_type::first_argument_type arg1,
+ typename self_type::second_argument_type arg2) const
+ {
+ return conv_(func_(arg1, arg2));
+ }
+
+ compconv2_(const C &conv, const BF &func)
+ : conv_(conv), func_(func)
+ {}
+ private:
+ const C conv_;
+ const BF func_;
+ };
+
+ } // end of internal
+
+ /*! Friendly procedure that build an internal::compconv1_ with
+ ** type deduction.
+ */
+ template <class C, class B, class UF>
+ internal::compconv1_<C, UF>
+ compconv1(const abstract::conversion<C, B>& conv, const UF &func)
+ {
+ return internal::compconv1_<C, UF>(conv.exact(), func);
+ }
+
+ /*! Likewise for compconv2_. */
+ template <class C, class B, class BF>
+ internal::compconv2_<C, BF>
+ compconv2(const abstract::conversion<C, B>& conv, const BF &func)
+ {
+ return internal::compconv2_<C, BF>(conv.exact(), func);
+ }
+
+
+ /*! Apply function that retrive the result type within the conversion class.
+ **
+ ** The core oln::apply function, cannot apply all conversion function,
+ ** because they do not all define result_type. So we define another
+ ** apply function here, to apply conversions.
+ */
+ template<class C, class B, class I> inline
+ typename mute<I, typename convoutput<C, B, oln_value_type(I)>::ret>::ret
+ apply(const abstract::conversion<C, B>& conv, const oln::abstract::image<I>& input)
+ {
+ /* CONV can now be wrapped as an Adaptable Unary Function
+ because we know the input type. Composing CONV with the
+ identity for the input type will cause such wrapping to
+ happen. */
+ return apply(compconv1(conv, f_identity<oln_value_type(I)>()), input);
+ }
+
+ } // convert
+
+ /* Export conversion and convouput into oln:: to simplify the
+ writing of processings. */
+ using convert::convoutput;
+
+} // oln
+
+
+#endif // OLENA_CONVERT_CONVERSION_HH
Index: trunk/milena/sandbox/vigouroux/convert/rgbxyz.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/convert/rgbxyz.hh (revision 0)
+++ trunk/milena/sandbox/vigouroux/convert/rgbxyz.hh (revision 1707)
@@ -0,0 +1,143 @@
+// Copyright (C) 2001, 2002, 2003, 2004 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, 59 Temple Place - Suite 330, 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 OLENA_CONVERT_RGBXYZ_HH
+# define OLENA_CONVERT_RGBXYZ_HH
+
+# include <oln/convert/abstract/colorconv.hh>
+
+# include <ntg/color/rgb.hh>
+# include <ntg/color/xyz.hh>
+# include <ntg/basics.hh>
+
+# include <sstream>
+
+/*! \file olena/oln/convert/rgbxyz.hh
+**
+** REF: The formulas used here come from ``Digital Image Processing
+** Algorithms and Applications'', I. Pitas; Wiley-Interscience.
+*/
+
+namespace oln {
+
+ using namespace ntg;
+
+ namespace convert {
+
+ /* Functor for conversion from RGB to XYZ.
+ **
+ ** \see f_rgb_to_hsl
+ */
+ template <unsigned inbits, unsigned outbits>
+ struct f_rgb_to_xyz
+ : public abstract::color_conversion<3, inbits, rgb_traits,
+ 3, outbits, xyz_traits, f_rgb_to_xyz <inbits, outbits> >
+ {
+ color<3, outbits, xyz_traits>
+ doit(const color<3, inbits, rgb_traits>& v) const
+ {
+ vec<3, float> in = v.to_float();
+ vec<3, float> out;
+ out[xyz_X] = 0.490 * in[rgb_R] + 0.310 * in[rgb_G] + 0.200 * in[rgb_B];
+ out[xyz_Y] = 0.177 * in[rgb_R] + 0.812 * in[rgb_G] + 0.011 * in[rgb_B];
+ out[xyz_Z] = 0.010 * in[rgb_G] + 0.990 * in[rgb_B];
+ return out;
+ }
+
+ static std::string
+ name()
+ {
+ std::ostringstream s;
+ s << "f_rgb_to_xyz<" << inbits << ", " << outbits << '>';
+ s.str();
+ }
+ };
+
+
+ /* Conversion from RGB to XYZ.
+ **
+ ** \see f_rgb_to_hsl
+ */
+ template <unsigned inbits, unsigned outbits>
+ color<3, outbits, xyz_traits>
+ rgb_to_xyz(const color<3, inbits, rgb_traits>& v)
+ {
+ f_rgb_to_xyz<inbits, outbits> f;
+
+ return f(v);
+ }
+
+ /* Functor for conversion from XYZ to RGB
+ **
+ ** \see f_rgb_to_hsl
+ */
+ template <unsigned inbits, unsigned outbits>
+ struct f_xyz_to_rgb
+ : public abstract::color_conversion<3, inbits, xyz_traits,
+ 3, outbits, rgb_traits, f_xyz_to_rgb <inbits, outbits> >
+ {
+ color<3, outbits, rgb_traits>
+ doit(const color<3, inbits, xyz_traits>& v) const
+ {
+ vec<3, float> in = v.to_float();
+ vec<3, float> out;
+ out[rgb_R] =
+ 2.365 * in[xyz_X] - 0.896 * in[xyz_Y] - 0.468 * in[xyz_Z];
+ out[rgb_G] =
+ - 0.515 * in[xyz_X] + 1.425 * in[xyz_Y] + 0.089 * in[xyz_Z];
+ out[rgb_B] =
+ 0.005 * in[xyz_X] - 0.014 * in[xyz_Y] + 1.01 * in[xyz_Z];
+ return out;
+ }
+
+ static std::string
+ name()
+ {
+ std::ostringstream s;
+ s << "f_xyz_to_rgb<" << inbits << ", " << outbits << '>';
+ s.str();
+ }
+ };
+
+ /* Functor for conversion from RGB to XYZ.
+ **
+ ** \see f_rgb_to_hsl
+ */
+ template <unsigned inbits, unsigned outbits>
+ color<3, outbits, rgb_traits>
+ xyz_to_rgb(const color<3, outbits, xyz_traits>& v)
+ {
+ f_xyz_to_rgb<inbits, outbits> f;
+
+ return f(v);
+ }
+
+ } // convert
+} // oln
+
+#endif // OLENA_CONVERT_RGBXYZ_HH
Index: trunk/milena/sandbox/vigouroux/convert/value_to_point.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/convert/value_to_point.hh (revision 0)
+++ trunk/milena/sandbox/vigouroux/convert/value_to_point.hh (revision 1707)
@@ -0,0 +1,131 @@
+// Copyright (C) 2004 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, 59 Temple Place - Suite 330, 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 OLENA_VALUE_TO_POINT
+# define OLENA_VALUE_TO_POINT
+# include <oln/core/point1d.hh>
+# include <oln/core/point3d.hh>
+# include <ntg/int.hh>
+# include <ntg/color/color.hh>
+# include <oln/convert/conversion.hh>
+namespace oln {
+
+ namespace convert {
+ /*! Convert a value of pixel to a point.
+ **
+ ** For example, transform an RGB color to a 3D point
+ ** (ntg::rgb_8 => oln::point3d).
+ ** This function is useful to build the histogram. \n
+ ** Example:
+ ** \verbatim
+ ** f(oln::convert::value_to_point<ntg::rgb_8>()(ntg::rgb_8(1,6,64)));
+ ** // is equivalent to:
+ ** f(oln::point3d(1, 6, 64));
+ ** \endverbatim
+ */
+ template <typename Argument_type,
+ class Exact = mlc::final>
+ struct value_to_point:
+ public abstract::conversion_from_type_to_type
+ <Argument_type,
+ point1d,
+ typename mlc::exact_vt<value_to_point<Argument_type,
+ Exact>,
+ Exact>::ret>
+ {
+ private:
+ /// By default a scalar is expected. If the type is a vector, a
+ /// specialization should be written.
+ typedef typename ntg_is_a(Argument_type, ntg::non_vectorial)::ensure_type ensure_type;
+ public:
+ /// By default return a point1d.
+ typedef point1d result_type;
+ typedef Argument_type argument_type;
+
+ /// Convert a binary to a point.
+ template <typename O, typename I>
+ struct doit_binary
+ {
+ static
+ O
+ doit(const I &input)
+ {
+ return input ? O(1) : O(0);
+ }
+ };
+ /// Convert a non vectorial to a point.
+ template <typename O, typename I>
+ struct doit_not_binary
+ {
+ static
+ O
+ doit(const I &input)
+ {
+ return O(input - ntg_min_val(I));
+ }
+ };
+
+ result_type
+ doit(const argument_type &input) const
+ {
+ typedef typename mlc::if_<ntg_is_a(argument_type, ntg::binary)::ret,
+ doit_binary<result_type, argument_type>,
+ doit_not_binary<result_type, argument_type> >::ret doit_type;
+ return doit_type::doit(input);
+ }
+ };
+
+ /*! Specialization for color of three dimension.
+ **
+ ** \todo Could be generalized to n dimensions if there were a trait that
+ ** give a pointkd for a given dimension k.
+ */
+ template <unsigned Qbits, template <unsigned> class S, class Exact>
+ struct value_to_point<ntg::color<3, Qbits, S>, Exact>:
+ public abstract::conversion_from_type_to_type
+ <typename ntg::color<3, Qbits, S>,
+ point3d,
+ typename mlc::exact_vt<value_to_point<typename ntg::color<3, Qbits, S>,
+ Exact>,
+ Exact>::ret>
+ {
+ public:
+ typedef point3d result_type;
+ typedef typename ntg::color<3, Qbits, S> argument_type;
+
+ result_type
+ doit(const argument_type &input) const
+ {
+ result_type r;
+ for (unsigned i = 0; i < 3; ++i)
+ r.nth(i) = oln::coord(input[i]);
+ return r;
+ }
+ };
+ }
+}
+#endif
Index: trunk/milena/sandbox/vigouroux/convert/cast.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/convert/cast.hh (revision 0)
+++ trunk/milena/sandbox/vigouroux/convert/cast.hh (revision 1707)
@@ -0,0 +1,63 @@
+// Copyright (C) 2001, 2002, 2003, 2004 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, 59 Temple Place - Suite 330, 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 OLENA_CONVERT_CAST_HH
+# define OLENA_CONVERT_CAST_HH
+
+# include <oln/convert/abstract/conversion.hh>
+# include <ntg/utils/cast.hh>
+
+namespace oln {
+ namespace convert {
+
+ /*! Cast to an output.
+ */
+ template<class Output, class Exact = mlc::final>
+ struct cast : public abstract::conversion_to_type< Output, typename mlc::exact_vt<cast<Output, Exact>, Exact>::ret >
+ {
+ template< class Input >
+ Output
+ doit(const Input& v) const
+ {
+ return v;
+ }
+
+ static std::string
+ name()
+ {
+ // FIXME: ntg_name(Exact) will not work for mlc::final !
+ return std::string("cast<")
+ + ntg_name(Output) + ", "
+ + "FIXME: ntg_name(Exact)" + ">";
+ }
+
+ };
+
+ } // convert
+} // oln
+
+#endif // OLENA_CONVERT_CAST_HH
Index: trunk/milena/sandbox/vigouroux/convert/rgbhsv.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/convert/rgbhsv.hh (revision 0)
+++ trunk/milena/sandbox/vigouroux/convert/rgbhsv.hh (revision 1707)
@@ -0,0 +1,204 @@
+// Copyright (C) 2001, 2002, 2003, 2004 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, 59 Temple Place - Suite 330, 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 OLENA_CONVERT_RGBHSV_HH
+# define OLENA_CONVERT_RGBHSV_HH
+
+# include <oln/basics.hh>
+# include <oln/convert/abstract/colorconv.hh>
+
+# include <ntg/basics.hh>
+# include <ntg/color/rgb.hh>
+# include <ntg/color/hsv.hh>
+
+# include <mlc/contract.hh>
+
+# include <sstream>
+
+/*! \file olena/oln/convert/rgbhsv.hh
+** REF: The formulas used here come from ``Color Conversion Algorithms''
+*/
+
+namespace oln {
+
+ using namespace ntg;
+
+ namespace convert {
+
+ /*! Functor for conversion from RGB to HSV.
+ **
+ ** \see f_rgb_to_hsl
+ */
+ template<unsigned inbits, unsigned outbits>
+ struct f_rgb_to_hsv
+ : public abstract::color_conversion<3, inbits, rgb_traits,
+ 3, outbits, hsv_traits, f_rgb_to_hsv<inbits, outbits> >
+ {
+ color<3, outbits, hsv_traits>
+ doit(const color<3, inbits, rgb_traits>& v) const
+ {
+ vec<3, float> in = v.to_float();
+ vec<3, float> out;
+ float max_in = std::max(in[rgb_R], std::max(in[rgb_B], in[rgb_G]));
+ float min_in = std::min(in[rgb_R], std::min(in[rgb_B], in[rgb_G]));
+ float delta = max_in - min_in;
+
+
+ out[hsv_V] = max_in;
+
+ if (max_in != 0)
+ out[hsv_S] = delta / max_in;
+ else
+ out[hsv_S] = 0;
+
+ if (out[hsv_S] == 0)
+ out[hsv_H] = -1; // undefined
+ else {
+ if (in[rgb_R] == max_in)
+ out[hsv_H] = (in[rgb_G] - in[rgb_B]) / delta;
+ else if (in[rgb_G] == max_in)
+ out[hsv_H] = 2 + (in[rgb_B] - in[rgb_R]) / delta;
+ else
+ out[hsv_H] = 4 + (in[rgb_R] - in[rgb_G]) / delta;
+ out[hsv_H] *= 60;
+ if (out[hsv_H] < 0)
+ out[hsv_H] += 360;
+ }
+
+ return out;
+ }
+
+ static std::string
+ name()
+ {
+ std::ostringstream s;
+ s << "f_rgb_to_hsv<" << inbits << ", " << outbits << '>';
+ s.str();
+ }
+ };
+
+ /*! Conversion from RGB to HSV.
+ **
+ ** \see f_rgb_to_hsl
+ */
+ template <unsigned inbits, unsigned outbits>
+ color<3, outbits, hsv_traits>
+ rgb_to_hsv(const color<3, inbits, rgb_traits>& v)
+ {
+ f_rgb_to_hsv<inbits, outbits> f;
+ return f(v);
+ }
+
+ /*! Functor conversion from HSV to RGB.
+ **
+ ** \see f_rgb_to_hsl
+ */
+ template<unsigned inbits, unsigned outbits>
+ struct f_hsv_to_rgb
+ : public abstract::color_conversion<3, inbits, hsv_traits,
+ 3, outbits, rgb_traits, f_hsv_to_rgb<inbits, outbits> >
+ {
+ color<3, outbits, rgb_traits>
+ doit(const color<3, inbits, hsv_traits>& v) const
+ {
+ vec<3, float> in = v.to_float();
+ vec<3, float> out;
+
+ if(in[hsv_S] == 0)
+ out[rgb_G] = out[rgb_B] = out[rgb_R] = in[hsv_V];
+ else
+ {
+ in[hsv_H] /= 60;
+ int i = (int)floor (in[hsv_H]);
+ float f = in[hsv_H] - i;
+ float p = in[hsv_V] * (1 - in[hsv_S]);
+ float q = in[hsv_V] * (1 - in[hsv_S] * f);
+ float t = in[hsv_V] * (1 - in[hsv_S] * (1 - f));
+
+ switch (i){
+ case 0:
+ case 6:
+ out[rgb_R] = in[hsv_V];
+ out[rgb_G] = t;
+ out[rgb_B] = p;
+ break;
+ case 1:
+ out[rgb_R] = q;
+ out[rgb_G] = in[hsv_V];
+ out[rgb_B] = p;
+ break;
+ case 2:
+ out[rgb_R] = p;
+ out[rgb_G] = in[hsv_V];
+ out[rgb_B] = t;
+ break;
+ case 3:
+ out[rgb_R] = p;
+ out[rgb_G] = q;
+ out[rgb_B] = in[hsv_V];
+ break;
+ case 4:
+ out[rgb_R] = t;
+ out[rgb_G] = p;
+ out[rgb_B] = in[hsv_V];
+ break;
+ default:
+ out[rgb_R] = in[hsv_V];
+ out[rgb_G] = p;
+ out[rgb_B] = q;
+ break;
+ }
+ }
+ return out;
+ }
+
+ static std::string
+ name()
+ {
+ std::ostringstream s;
+ s << "f_hsv_to_rgb<" << inbits << ", " << outbits << '>';
+ s.str();
+ }
+ };
+
+ /*! Conversion from HSV to RGB.
+ **
+ ** \see f_rgb_to_hsl
+ */
+ template <unsigned inbits, unsigned outbits>
+ color<3, outbits, rgb_traits>
+ hsv_to_rgb(const color<3, inbits, hsv_traits>& v)
+ {
+ f_hsv_to_rgb<inbits, outbits> f;
+ return f(v);
+ }
+
+ } // convert
+} // oln
+
+#endif // OLENA_CONVERT_RGBHSV_HH
Index: trunk/milena/sandbox/vigouroux/convert/rgbyiq.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/convert/rgbyiq.hh (revision 0)
+++ trunk/milena/sandbox/vigouroux/convert/rgbyiq.hh (revision 1707)
@@ -0,0 +1,141 @@
+// Copyright (C) 2001, 2002, 2003, 2004 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, 59 Temple Place - Suite 330, 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 OLENA_CONVERT_RGBYIQ_HH
+# define OLENA_CONVERT_RGBYIQ_HH
+
+# include <oln/convert/abstract/colorconv.hh>
+
+# include <ntg/color/rgb.hh>
+# include <ntg/color/yiq.hh>
+# include <ntg/basics.hh>
+
+# include <sstream>
+
+/*! \file olena/oln/convert/rgbyiq.hh
+**
+** REF: The formulas used here come from ``Digital Image Processing
+** Algorithms and Applications'', I. Pitas; Wiley-Interscience.
+*/
+namespace oln {
+
+ using namespace ntg;
+
+ namespace convert {
+
+ /* Functor for conversion from RGB to YIQ.
+ **
+ ** \see f_rgb_to_hsl
+ */
+ template<unsigned inbits, unsigned outbits>
+ struct f_rgb_to_yiq
+ : public abstract::color_conversion<3, inbits, rgb_traits,
+ 3, outbits, yiq_traits, f_rgb_to_yiq<inbits, outbits> >
+ {
+ color<3, inbits, yiq_traits>
+ doit(const color<3, outbits, rgb_traits>& v) const
+ {
+ vec<3, float> in = v.to_float();
+ vec<3, float> out;
+ out[yiq_Y] =
+ 0.1768 * in[rgb_R] + 0.8130 * in[rgb_G] + 0.0101 * in[rgb_B];
+ out[yiq_I] =
+ 0.5346 * in[rgb_R] - 0.2461 * in[rgb_G] - 0.1791 * in[rgb_B];
+ out[yiq_Q] =
+ 0.2474 * in[rgb_R] - 0.6783 * in[rgb_G] + 0.4053 * in[rgb_B];
+ return out;
+ }
+
+ static std::string
+ name()
+ {
+ std::ostringstream s;
+ s << "f_rgb_to_yiq<" << inbits << ", " << outbits << '>';
+ s.str();
+ }
+ };
+
+ /* Conversion from RGB to YIQ.
+ **
+ ** \see f_rgb_to_hsl
+ */
+ template <unsigned inbits, unsigned outbits>
+ color<3, outbits, yiq_traits>
+ rgb_to_yiq(const color<3, inbits, rgb_traits>& v)
+ {
+ f_rgb_to_yiq<inbits, outbits> f;
+
+ return f(v);
+ }
+
+ /* Functor for conversion from YIQ to RGB.
+ **
+ ** \see f_rgb_to_hsl
+ */
+ template<unsigned inbits, unsigned outbits>
+ struct f_yiq_to_rgb
+ : public abstract::color_conversion<3, inbits, yiq_traits,
+ 3, outbits, rgb_traits, f_yiq_to_rgb<inbits, outbits> >
+ {
+ color<3, inbits, rgb_traits>
+ doit(const color<3, outbits, yiq_traits>& v) const
+ {
+ vec<3, float> in = v.to_float();
+ vec<3, float> out;
+ out[rgb_R] = 0.87 * in[yiq_Y] + 1.3223 * in[yiq_I] + 0.5628 * in[yiq_Q];
+ out[rgb_G] = 1.026 * in[yiq_Y] - 0.2718 * in[yiq_I] - 0.1458 * in[yiq_Q];
+ out[rgb_B] = 1.186 * in[yiq_Y] - 1.2620 * in[yiq_I] + 1.8795 * in[yiq_Q];
+ return out;
+ }
+
+ static std::string
+ name()
+ {
+ std::ostringstream s;
+ s << "f_yiq_to_rgb<" << inbits << ", " << outbits << '>';
+ s.str();
+ }
+ };
+
+ /* Conversion from YIQ to RGB.
+ **
+ ** \see f_rgb_to_hsl
+ */
+ template <unsigned inbits, unsigned outbits>
+ color<3, outbits, rgb_traits>
+ yiq_to_rgb(const color<3, inbits, yiq_traits>& v)
+ {
+ f_yiq_to_rgb<inbits, outbits> f;
+
+ return f(v);
+ }
+
+ } // convert
+} // oln
+
+#endif // OLENA_CONVERT_RGBYIQ_HH
Index: trunk/milena/sandbox/vigouroux/convert/force.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/convert/force.hh (revision 0)
+++ trunk/milena/sandbox/vigouroux/convert/force.hh (revision 1707)
@@ -0,0 +1,62 @@
+// Copyright (C) 2001, 2002, 2003, 2004 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, 59 Temple Place - Suite 330, 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 OLENA_CONVERT_FORCE_HH
+# define OLENA_CONVERT_FORCE_HH
+
+# include <oln/convert/abstract/conversion.hh>
+# include <ntg/utils/cast.hh>
+
+namespace oln {
+ namespace convert {
+
+ /*! Like cast::force, but as a conversion functor. */
+ template<class Output, class Exact = mlc::final>
+ struct force : public abstract::conversion_to_type< Output, typename mlc::exact_vt<force<Output, Exact>, Exact>::ret >
+ {
+ template< class Input >
+ Output
+ doit(const Input& v) const
+ {
+ return ntg::cast::force<Output>(v);
+ }
+
+ static std::string
+ name()
+ {
+ // FIXME: Exact is not an integre type !
+ return std::string("force<")
+ + ntg_name(Output) + ", "
+ + Exact::name() + ">";
+ }
+ };
+
+ } // convert
+} // oln
+
+#endif // OLENA_CONVERT_FORCE_HH
Index: trunk/milena/sandbox/vigouroux/convert/conversion_ng_se.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/convert/conversion_ng_se.hh (revision 0)
+++ trunk/milena/sandbox/vigouroux/convert/conversion_ng_se.hh (revision 1707)
@@ -0,0 +1,82 @@
+// Copyright (C) 2002, 2004 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, 59 Temple Place - Suite 330, 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 OLENA_CONVERT_CONVERSION_NG_SE_HH
+# define OLENA_CONVERT_CONVERSION_NG_SE_HH
+
+# include <oln/basics.hh>
+
+// because of the internal function in this file
+# include <oln/basics1d.hh>
+# include <oln/basics2d.hh>
+# include <oln/basics3d.hh>
+# include <oln/core/neighborhood1d.hh>
+# include <oln/core/neighborhood2d.hh>
+# include <oln/core/neighborhood3d.hh>
+
+namespace oln {
+ namespace convert {
+ /*! Convert a neighborhood to a window.
+ **
+ ** \see ng_to_cse
+ */
+ template<class N>
+ typename oln::abstract::neighborhood<N>::win_type
+ ng_to_se(const oln::abstract::neighborhood<N>& Ng)
+ {
+ typename oln::abstract::neighborhood<N>::win_type output;
+ oln_iter_type(N) p(Ng);
+ for_all(p)
+ output.add(p);
+ return output;
+ }
+
+ /*! Convert a neighborhood to a window and add the center.
+ **
+ ** \see ng_to_cs
+ */
+ template<class N>
+ typename oln::abstract::neighborhood<N>::win_type
+ ng_to_cse(const oln::abstract::neighborhood<N>& Ng)
+ {
+ typename oln::abstract::neighborhood<N>::win_type output;
+ oln_iter_type(N) p(Ng);
+ for_all(p)
+ output.add(p);
+ oln_dpoint_type(N) zero;
+ for (unsigned size = 0; size < N::dim; ++size)
+ zero.nth(size) = 0;
+ output.add(zero);
+ return output;
+ }
+
+
+ } // convert
+} // oln
+
+
+#endif // OLENA_CONVERT_CONVERSION_NG_SE_HH
Index: trunk/milena/sandbox/vigouroux/convert/nrgbxyz.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/convert/nrgbxyz.hh (revision 0)
+++ trunk/milena/sandbox/vigouroux/convert/nrgbxyz.hh (revision 1707)
@@ -0,0 +1,181 @@
+// Copyright (C) 2001, 2002, 2003, 2004 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, 59 Temple Place - Suite 330, 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 OLENA_CONVERT_NRGBXYZ_HH
+# define OLENA_CONVERT_NRGBXYZ_HH
+
+# include <oln/convert/abstract/colorconv.hh>
+
+# include <ntg/color/nrgb.hh>
+# include <ntg/color/xyz.hh>
+# include <ntg/basics.hh>
+
+# include <sstream>
+
+/*! \file olena/oln/convert/nrgbxyz.hh
+**
+** REF: The formulas used here come from ``Digital Image Processing
+** Algorithms and Applications'', I. Pitas; Wiley-Interscience.
+*/
+
+namespace oln {
+
+ // FIXME: should it be removed?
+ using namespace ntg;
+
+ namespace convert {
+
+ /*! Functor for conversion from N-RGB to XYZ color space.
+ **
+ ** \deprecated A composition should be performed with nrgb->rgb and rgb->xyz. It has
+ ** not been replaced within the function because a double conversion 'reduces'
+ ** the color space. See the following example:
+ ** \code
+ ** // Obsolete:
+ ** //
+ ** // #include <oln/convert/nrgbxyz.hh>
+ ** // #include <ntg/all.hh>
+ ** // int main(int argc, char **argv)
+ ** // {
+ ** // ntg::nrgb_8 in(100, 60, 64);
+ ** // ntg::xyz_8 out = oln::convert::f_nrgb_to_xyz<8, 8>()(in);
+ ** // }
+ ** //
+ ** // Should be replaced by:
+ ** //
+ ** #include <oln/convert/rgbxyz.hh>
+ ** #include <oln/convert/rgbnrgb.hh>
+ ** #include <ntg/all.hh>
+ ** int main()
+ ** {
+ ** ntg::nrgb_8 in(100, 60, 64);
+ ** ntg::xyz_8 out = oln::convert::f_rgb_to_xyz<8, 8>()
+ ** (oln::convert::f_nrgb_to_rgb<8, 8>()(in));
+ ** }
+ ** \endcode
+ */
+ template <unsigned inbits, unsigned outbits>
+ struct f_nrgb_to_xyz
+ : public abstract::color_conversion<3, inbits, nrgb_traits,
+ 3, outbits, xyz_traits, f_nrgb_to_xyz<inbits, outbits> >
+ {
+ color<3, outbits, xyz_traits>
+ doit(const color<3, inbits, nrgb_traits>& v) const
+ {
+ vec<3, float> in = v.to_float();
+ vec<3, float> out;
+ out[xyz_X] =
+ 0.606734 * in[nrgb_R] + 0.173564 * in[nrgb_G] + 0.200112 * in[nrgb_B];
+
+ out[xyz_Y] =
+ 0.298839 * in[nrgb_R] + 0.586811 * in[nrgb_G] + 0.114350 * in[nrgb_B];
+
+ out[xyz_Z] =
+ 0.0661196 * in[nrgb_G] + 1.11491 * in[nrgb_B];
+
+ return out;
+ }
+
+ static std::string
+ name()
+ {
+ std::ostringstream s;
+ s << "f_nrgb_to_xyz<" << inbits << ", " << outbits << '>';
+ s.str();
+ }
+ };
+
+ /*! Conversion from N-RGB to XYZ color space.
+ **
+ ** \deprecated A composition should be performed with nrgb->rgb and rgb->xyz.
+ **
+ ** \see f_nrgb_to_xyz for more information.
+ */
+ template <unsigned inbits, unsigned outbits>
+ color<3, outbits, xyz_traits>
+ nrgb_to_xyz(const color<3, inbits, nrgb_traits>& v)
+ {
+ f_nrgb_to_xyz<inbits, outbits> f;
+
+ return f(v);
+ }
+
+ /*! Functor for conversion from XYZ to N-RGB color space.
+ **
+ ** \deprecated A composition should be performed with xyz->rgb and rgb->nrgb.
+ **
+ ** \see f_nrgb_to_xyz for more information.
+ */
+ template<unsigned inbits, unsigned outbits>
+ struct f_xyz_to_nrgb
+ : public abstract::color_conversion<3, inbits, xyz_traits,
+ 3, outbits, nrgb_traits, f_xyz_to_nrgb<inbits, outbits> >
+ {
+ color<3, outbits, nrgb_traits>
+ doit(const color<3, inbits, xyz_traits>& v) const
+ {
+ vec<3, float> in = v.to_float();
+ vec<3, float> out;
+ out[nrgb_R] =
+ 1.91049 * in[xyz_X] - 0.532592 * in[xyz_Y] - 0.288284 * in[xyz_Z];
+ out[nrgb_G] =
+ - 0.984310 * in[xyz_X] + 1.99845 * in[xyz_Y] - 0.0282980 * in[xyz_Z];
+ out[nrgb_B] =
+ 0.0583744 * in[xyz_X] - 0.118518 * in[xyz_Y] + 0.898611 * in[xyz_Z];
+ return out;
+ }
+
+ static std::string
+ name()
+ {
+ std::ostringstream s;
+ s << "f_xyz_to_nrgb<" << inbits << ", " << outbits << '>';
+ s.str();
+ }
+ };
+
+
+ /*! Conversion from XYZ to N-RGB color space.
+ **
+ ** \deprecated a composition should be performed with xyz->rgb and rgb->nrgb.
+ **
+ ** \see f_nrgb_to_xyz for more information.
+ */
+ template <unsigned inbits, unsigned outbits>
+ color<3, outbits, nrgb_traits>
+ xyz_to_nrgb(const color<3, inbits, xyz_traits>& v)
+ {
+ f_xyz_to_nrgb<inbits, outbits> f;
+
+ return f(v);
+ }
+
+ } // convert
+} // oln
+
+#endif // OLENA_CONVERT_NRGBXYZ_HH
Index: trunk/milena/sandbox/vigouroux/convert/basics.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/convert/basics.hh (revision 0)
+++ trunk/milena/sandbox/vigouroux/convert/basics.hh (revision 1707)
@@ -0,0 +1,38 @@
+// Copyright (C) 2001, 2002, 2003, 2004 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, 59 Temple Place - Suite 330, 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 OLENA_CONVERT_BASICS_HH
+# define OLENA_CONVERT_BASICS_HH
+
+# include <oln/convert/abstract/conversion.hh>
+# include <oln/convert/conversion.hh>
+# include <oln/convert/cast.hh>
+# include <oln/convert/force.hh>
+# include <oln/convert/bound.hh>
+# include <oln/convert/stretch.hh>
+
+#endif // OLENA_CONVERT_BASICS_HH
Index: trunk/milena/sandbox/vigouroux/convert/abstract/colorconv.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/convert/abstract/colorconv.hh (revision 0)
+++ trunk/milena/sandbox/vigouroux/convert/abstract/colorconv.hh (revision 1707)
@@ -0,0 +1,68 @@
+// Copyright (C) 2001, 2002, 2003, 2004 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, 59 Temple Place - Suite 330, 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 OLENA_CONVERT_ABSTRACT_COLORCONV_HH
+# define OLENA_CONVERT_ABSTRACT_COLORCONV_HH
+
+# include <ntg/color/color.hh>
+# include <oln/convert/abstract/conversion.hh>
+
+namespace oln {
+
+ namespace convert {
+
+ namespace abstract {
+
+ /*! Base class for color conversion.
+ **
+ ** \param icomps Number of components in the input.
+ ** \param iqbits Number of bits per components in the input.
+ ** \param icolor Input color.
+ ** \param ocomps Number of components in the output.
+ ** \param oqbits Number of bits per components in the output.
+ ** \param ocolor Output color.
+ ** \param Exact Exact class.
+ */
+ template< unsigned icomps,
+ unsigned iqbits,
+ template<unsigned> class icolor,
+ unsigned ocomps,
+ unsigned oqbits,
+ template<unsigned> class ocolor,
+ class Exact = mlc::final >
+ struct color_conversion :
+ public abstract::conversion_from_type_to_type< ntg::color<icomps, iqbits, icolor>,
+ ntg::color<ocomps, oqbits, ocolor>,
+ typename mlc::exact_vt<color_conversion<icomps, iqbits, icolor, ocomps, oqbits, ocolor, Exact>, Exact>::ret >
+ {
+ };
+ }
+ } // convert
+} // oln
+
+
+#endif // OLENA_CONVERT_ABSTRACT_COLORCONV_HH
Index: trunk/milena/sandbox/vigouroux/convert/abstract/conversion.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/convert/abstract/conversion.hh (revision 0)
+++ trunk/milena/sandbox/vigouroux/convert/abstract/conversion.hh (revision 1707)
@@ -0,0 +1,177 @@
+// Copyright (C) 2001, 2002, 2003, 2004 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, 59 Temple Place - Suite 330, 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 OLENA_CONVERT_ABSTRACT_CONVERSION_HH
+# define OLENA_CONVERT_ABSTRACT_CONVERSION_HH
+
+# include <mlc/type.hh>
+# include <ntg/utils/debug.hh>
+# include <functional>
+
+namespace oln {
+ namespace convert {
+ /*!
+ ** \brief Base classes for conversion.
+ */
+ namespace abstract {
+
+ // fwd_decl
+ template <class Exact, class Base>
+ class conversion;
+
+ template<class Result_Type,
+ class Exact, class Base>
+ struct conversion_to_type;
+
+ template<class Argument_Type, class Result_Type,
+ class Exact, class Base>
+ struct conversion_from_type_to_type;
+
+ template<class Conv>
+ struct conversion_traits;
+
+ /*! \brief Internal purpose only.
+ */
+ namespace internal {
+ /// Retrieve the result type of a conversion.
+ template <class Base, class T>
+ struct output {};
+
+ template <class Argument_Type, class Result_Type,
+ class Exact, class Base>
+ struct output<conversion_from_type_to_type<Argument_Type, Result_Type, Exact, Base >, Argument_Type>
+ {
+ typedef Result_Type ret;
+ };
+
+ template <class Result_Type,
+ class Exact, class Base, class T>
+ struct output<conversion_to_type<Result_Type, Exact, Base >, T>
+ {
+ typedef Result_Type ret;
+ };
+ }
+
+ } // end of namespace abstract
+
+ namespace abstract {
+ /*! Base class for conversion.
+ **
+ ** \note If you write an class derived from this one, you
+ ** must write the specialization of the output trait.
+ */
+ template<class Exact, class Base>
+ struct conversion : public mlc_hierarchy::any< Exact >
+ {
+ static std::string
+ name()
+ {
+ return std::string("conversion<") + Exact::name() + ">";
+ }
+
+ public:
+ template<class T>
+ struct output
+ {
+ typedef typename internal::output<Base, T>::ret ret;
+ };
+
+ /// Call the conversion written in the exact class.
+ template <class T>
+ typename output<T>::ret
+ operator()(const T& in) const
+ {
+ return this->exact().doit(in);
+ }
+
+ protected:
+ conversion() {}
+ };
+
+ /// Base class for the conversion to a specific type.
+ template<class Result_Type, class Exact = mlc::final, class Base = mlc::final>
+ struct conversion_to_type :
+ public conversion< typename mlc::exact_vt<conversion_to_type< Result_Type, Exact >, Exact>::ret,
+ typename mlc::exact_vt<conversion_to_type< Result_Type, Exact >, Base>::ret >
+ {
+ /* Additionally define result_type. This is not required
+ in a conversion class (generally not possible to define).
+ But it's useful when it's available (like here)
+ because it make the conversion appear almost as Adaptable
+ Unary Function (it will just lack the argument_type, but
+ this typedef is not used very much.) */
+
+ typedef Result_Type result_type;
+
+ static std::string
+ name()
+ {
+ // FIXME: Exact is not an integre type !
+ return std::string("conversion_to_type<")
+ + ntg_name(Result_Type) + ", "
+ + Exact::name() + ">";
+ }
+
+ protected:
+ conversion_to_type() {}
+ };
+
+ /// Base class if both input and output types of the conversion are fixed.
+ template<class Argument_Type, class Result_Type,
+ class Exact = mlc::final, class Base = mlc::final>
+ struct conversion_from_type_to_type:
+ public conversion_to_type< Result_Type,
+ typename mlc::exact_vt<conversion_from_type_to_type< Argument_Type, Result_Type, Base, Exact>, Exact>::ret,
+ typename mlc::exact_vt<conversion_from_type_to_type< Argument_Type, Result_Type, Base, Exact>, Base>::ret >
+ {
+
+ /* By defining argument_type, and inheriting from result_type,
+ we comply to the STL concept of Adaptable Unary Function. */
+
+ typedef Argument_Type argument_type;
+
+ static std::string
+ name()
+ {
+ // FIXME: Exact is not an integre type !
+ return std::string("conversion_from_type_to_type<")
+ + ntg_name(Argument_Type) + ", "
+ + ntg_name(Result_Type) + ", "
+ + "FIXME: ntg_name(Exact)" + ">";
+ }
+
+ protected :
+ conversion_from_type_to_type() {}
+ };
+ }
+
+ } // convert
+
+} // oln
+
+
+#endif // OLENA_CONVERT_ABSTRACT_CONVERSION_HH
Index: trunk/milena/sandbox/vigouroux/convert/bound.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/convert/bound.hh (revision 0)
+++ trunk/milena/sandbox/vigouroux/convert/bound.hh (revision 1707)
@@ -0,0 +1,66 @@
+// Copyright (C) 2001, 2002, 2003, 2004 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, 59 Temple Place - Suite 330, 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 OLENA_CONVERT_BOUND_HH
+# define OLENA_CONVERT_BOUND_HH
+
+# include <oln/convert/abstract/conversion.hh>
+# include <ntg/utils/cast.hh>
+
+namespace oln {
+ namespace convert {
+
+ /*! Like convert::force, but with saturation.
+ **
+ ** \todo FIXME: is this really useful with new types ?
+ */
+ template<class Output, class Exact = mlc::final>
+ struct bound : public abstract::conversion_to_type< Output, typename mlc::exact_vt<bound<Output, Exact>, Exact>::ret >
+ {
+
+ template< class Input >
+ Output
+ doit(const Input& v) const
+ {
+ return ntg::cast::bound<Output>(v);
+ }
+
+ static std::string
+ name()
+ {
+ // FIXME: ntg_name(Exact) will not work for mlc::final !
+ return std::string("bound<")
+ + ntg_name(Output) + ", "
+ + "FIXME: ntg_name(Exact)" + ">";
+ }
+ };
+
+ } // convert
+} // oln
+
+#endif // OLENA_CONVERT_BOUND_HH
Index: trunk/milena/sandbox/vigouroux/convert/stretch.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/convert/stretch.hh (revision 0)
+++ trunk/milena/sandbox/vigouroux/convert/stretch.hh (revision 1707)
@@ -0,0 +1,217 @@
+// Copyright (C) 2001, 2002, 2003, 2004 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, 59 Temple Place - Suite 330, 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 OLENA_CONVERT_STRETCH_HH
+# define OLENA_CONVERT_STRETCH_HH
+
+# include <mlc/type.hh>
+
+# include <oln/basics.hh>
+
+# include <ntg/basics.hh>
+
+# include <oln/convert/abstract/conversion.hh>
+
+# include <set>
+
+# include <vector>
+
+namespace oln {
+
+ namespace convert {
+
+ /*! Functor to stretch a value from a range Input to a range Output.
+ **
+ ** \see stretch_balance
+ ** \code
+ ** #include <oln/basics2d.hh>
+ ** #include <oln/convert/stretch.hh>
+ ** #include <ntg/all.hh>
+ ** #include <iostream>
+ **
+ ** int main()
+ ** {
+ ** oln::image2d<ntg::int_u8> lena = oln::load(IMG_IN "lena256.pgm");
+ **
+ ** oln::io::save(apply(oln::convert::stretch<ntg::int_u<3> >(), lena),
+ ** IMG_OUT "oln_convert_stretch.pgm");
+ ** }
+ ** \endcode
+ ** \image html lena256_pgm.png
+ ** \image latex lena256_pgm.png
+ ** =>
+ ** \image html oln_convert_stretch.png
+ ** \image latex oln_convert_stretch.png
+ */
+ template<class Output, class Exact = mlc::final>
+ struct stretch
+ : public abstract::conversion_to_type<Output, typename mlc::exact_vt<stretch<Output, Exact>, Exact>::ret >
+ {
+ template< class Input >
+ Output doit(const Input& v) const {
+ return Output(ntg::cast::rbound<Output, float>
+ (
+ double(v - ntg_min_val(Input))
+ / double(ntg_max_val(Input) - ntg_min_val(Input))
+ * (ntg_max_val(Output) - ntg_min_val(Output))
+ + ntg_min_val(Output))
+ );
+ }
+
+ static std::string
+ name()
+ {
+ // FIXME: Exact is not an integre type !
+ return std::string("stretch<") + ntg_name(Output) + ", "
+ + Exact::name() + ">";
+ }
+ };
+
+ /*! Stretch the value of an image.
+ **
+ ** This function stretches values between \a min_in and \a max_in
+ ** of an image \a in, to a range that goes from \a min_out to \a max_out.
+ ** \arg in Input image, must be have scalar values
+ ** \arg min_in Lower bound of the range in the input. All values smaller
+ ** than min_in are converted to \a min_out.
+ ** \arg max_in Upper bound of the range in the input. All values
+ ** greater than max_in
+ ** are converted to \a max_out.
+ ** \arg min_out Low bound of the range in the output.
+ ** \arg max_out Upper bound of the range in the output.
+ **
+ ** Difference between "apply(stretch<T>(), im)" and "stretch_balance<T>(im)":
+ ** the first one stretches all the range of oln_value_type(T), the second
+ ** stretches only values that appear is the image:
+ ** \code
+ ** #include <oln/basics1d.hh>
+ ** #include <oln/convert/stretch.hh>
+ ** #include <ntg/all.hh>
+ ** #include <iostream>
+ **
+ ** int main()
+ ** {
+ **
+ ** oln::image1d<ntg::int_u<17> > im(4);
+ ** im(0) = 0; im(1) = 2; im(2) = 5000; im(3) = 4000;
+ **
+ ** // print "0 170 511 340"
+ ** //(values of the *image* are dispatched on the range [0..2^9-1])
+ ** std::cout << oln::convert::stretch_balance<ntg::int_u<9> >(im) << std::endl;
+ **
+ ** //print " 0 0 19 16" (19 is the result of 5000 * 2^9 / 2^17)
+ ** //(values of *int_u<17>* are dispatched on the range [0..2^9-1])
+ ** std::cout << apply(oln::convert::stretch<ntg::int_u<9> >(), im) << std::endl;
+ ** }
+ ** \endcode
+ **
+ ** This function is useful to stretch images of label:
+ ** \code
+ ** #include <oln/basics2d.hh>
+ ** #include <oln/convert/stretch.hh>
+ ** #include <oln/level/cc.hh>
+ ** #include <ntg/all.hh>
+ ** #include <iostream>
+ **
+ ** int main()
+ ** {
+ ** oln::image2d<ntg::bin> light = oln::load(IMG_IN "face_se.pbm");
+ **
+ ** //Extraction of the connected components:
+ ** unsigned card;
+ ** oln::image2d<ntg::int_u8> cc
+ ** = oln::level::frontp_connected_component<ntg::int_u8>(light,
+ ** oln::neighb_c8(),
+ ** card);
+ ** oln::io::save(cc, IMG_OUT "oln_convert_stretch_dark.pgm");
+ ** oln::io::save(oln::convert::stretch_balance<ntg::int_u8>(cc),
+ ** IMG_OUT "oln_convert_stretch_balance.pgm");
+ ** }
+ ** \endcode
+ ** \image html face_se_pbm.png
+ ** \image latex face_se_pbm.png
+ ** => Without stretch_balance:
+ ** \image html oln_convert_stretch_dark.png
+ ** \image latex oln_convert_stretch_dark.png
+ ** => With stretch_balance:
+ ** \image html oln_convert_stretch_balance.png
+ ** \image latex oln_convert_stretch_balance.png
+ */
+ template<class DestValue, class I>
+ typename mute<I, DestValue>::ret
+ stretch_balance(const oln::abstract::non_vectorial_image<I> &in,
+ const oln_value_type(I) & min_in
+ = ntg_min_val(oln_value_type(I)),
+ const oln_value_type(I) & max_in
+ = ntg_max_val(oln_value_type(I)),
+ const DestValue & min_out = ntg_min_val(DestValue),
+ const DestValue & max_out = ntg_max_val(DestValue))
+ {
+ typedef typename
+ ntg_is_a(DestValue, ntg::non_vectorial)::ensure_type ensure_type;
+
+ typename mute<I, DestValue>::ret out(in.size());
+
+ //FIXME: I would like to remove the static_cast.
+ std::vector<ntg_cumul_type(DestValue)>
+ tab(static_cast<int>(max_in - min_in + 1));
+ typedef typename std::set<oln_value_type(I)> set_type;
+ set_type s;
+ oln_iter_type(I) it(in);
+
+ for_all(it)
+ if (in[it] <= max_in && in[it] >= min_in)
+ s.insert(in[it]);
+ if (s.size() == 1)
+ {
+ for_all(it)
+ out[it] = ntg_zero_val(DestValue);
+ return out;
+ }
+ {
+ unsigned cpt = 0;
+ for (typename set_type::const_iterator it(s.begin());
+ it != s.end(); ++it, ++cpt)
+ tab[*it - min_in] = cpt * (max_out - min_out) / (s.size() - 1);
+ }
+ for_all(it)
+ if (min_in <= in[it])
+ {
+ if (in[it] <= max_in)
+ out[it] = tab[in[it] - min_in] + min_out;
+ else
+ out[it] = max_out;
+ }
+ else
+ out[it] = min_out;
+ return out;
+ }
+ } // end of convert.
+
+} // end of oln.
+
+#endif // OLENA_CONVERT_STRETCH_HH
Index: trunk/milena/sandbox/vigouroux/convert/rgbyuv.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/convert/rgbyuv.hh (revision 0)
+++ trunk/milena/sandbox/vigouroux/convert/rgbyuv.hh (revision 1707)
@@ -0,0 +1,139 @@
+// Copyright (C) 2001, 2002, 2003, 2004 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, 59 Temple Place - Suite 330, 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 OLENA_CONVERT_NRGBYUV_HH
+# define OLENA_CONVERT_NRGBYUV_HH
+
+# include <oln/convert/abstract/colorconv.hh>
+
+# include <ntg/color/rgb.hh>
+# include <ntg/color/yuv.hh>
+# include <ntg/basics.hh>
+
+# include <sstream>
+
+/*!\file olena/oln/convert/rgbyuv.hh
+**
+** REF: The formulas used here come from ``Colour Space Conversions'',
+** IAdrian Ford and Alan Roberts; August 11,1998.
+*/
+namespace oln {
+
+ using namespace ntg;
+
+ namespace convert {
+ /* Functor for conversion from RGB to YUV.
+ **
+ ** \see f_rgb_to_hsl
+ */
+ template <unsigned inbits, unsigned outbits>
+ struct f_rgb_to_yuv
+ : public abstract::color_conversion<3, inbits, rgb_traits,
+ 3, outbits, yuv_traits, f_rgb_to_yuv<inbits, outbits> >
+ {
+ color<3, outbits, yuv_traits>
+ doit(const color<3, inbits, rgb_traits>& v) const
+ {
+ vec<3, float> in = v.to_float();
+ vec<3, float> out;
+ out[yuv_Y] =
+ + 0.177 * in[rgb_R] + 0.813 * in[rgb_G] + 0.01 * in[rgb_B];
+ out[yuv_U] =
+ - 0.083 * in[rgb_R] - 0.434 * in[rgb_G] + 0.437 * in[rgb_B];
+ out[yuv_V] =
+ + 0.583 * in[rgb_R] - 0.576 * in[rgb_G] + 0.071 * in[rgb_B];
+ return out;
+ }
+
+ static std::string
+ name()
+ {
+ std::ostringstream s;
+ s << "f_rgb_to_yuv<" << inbits << ", " << outbits << '>';
+ s.str();
+ }
+ };
+ /* Conversion from RGB to YUV.
+ **
+ ** \see f_rgb_to_hsl
+ */
+ template <unsigned inbits, unsigned outbits>
+ color<3, outbits, yuv_traits>
+ rgb_to_yuv(const color<3, inbits, rgb_traits>& v)
+ {
+ f_rgb_to_yuv<inbits, outbits> f;
+
+ return f(v);
+ }
+ /* Functor for conversion from YUV to RGB.
+ **
+ ** \see f_rgb_to_hsl
+ */
+ template<unsigned inbits, unsigned outbits>
+ struct f_yuv_to_rgb
+ : public abstract::color_conversion<3, inbits, yuv_traits,
+ 3, outbits, rgb_traits, f_yuv_to_rgb<inbits, outbits> >
+ {
+ color<3, outbits, rgb_traits>
+ doit(const color<3, inbits, yuv_traits>& v) const
+ {
+ vec<3, float> in = v.to_float();
+ vec<3, float> out;
+ out[rgb_R] = 0.8702 * in[yuv_Y] - 0.2487 * in[yuv_U] + 1.4250 * in[yuv_V];
+ out[rgb_G] = 1.0259 * in[yuv_Y] + 0.0259 * in[yuv_U] - 0.3072 * in[yuv_V];
+ out[rgb_B] = 1.1837 * in[yuv_Y] + 2.2642 * in[yuv_U] - 0.0359 * in[yuv_V];
+
+ return out;
+ }
+
+ static std::string
+ name()
+ {
+ std::ostringstream s;
+ s << "f_yuv_to_rgb<" << inbits << ", " << outbits << '>';
+ s.str();
+ }
+ };
+
+ /* Conversion from YUV to RGB.
+ **
+ ** \see f_rgb_to_hsl
+ */
+ template <unsigned inbits, unsigned outbits>
+ color<3, outbits, rgb_traits>
+ yuv_to_rgb(const color<3, inbits, yuv_traits>& v)
+ {
+ f_yuv_to_rgb<inbits, outbits> f;
+
+ return f(v);
+ }
+
+ } // convert
+} // oln
+
+#endif // OLENA_CONVERT_RGBYUV_HH
Index: trunk/milena/sandbox/vigouroux/convert/rgbhsi.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/convert/rgbhsi.hh (revision 0)
+++ trunk/milena/sandbox/vigouroux/convert/rgbhsi.hh (revision 1707)
@@ -0,0 +1,153 @@
+// Copyright (C) 2001, 2002, 2003, 2004 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, 59 Temple Place - Suite 330, 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 OLENA_CONVERT_RGBHSI_HH
+# define OLENA_CONVERT_RGBHSI_HH
+
+# include <oln/convert/abstract/colorconv.hh>
+
+# include <ntg/basics.hh>
+# include <ntg/color/rgb.hh>
+# include <ntg/color/hsi.hh>
+
+# include <sstream>
+
+/*! \file olena/oln/convert/rgbhsi.hh
+**
+** REF: The formulas used here come from ``Digital Image Processing
+** Algorithms and Applications'', I. Pitas; Wiley-Interscience.
+*/
+
+namespace oln {
+
+ using namespace ntg;
+
+ namespace convert {
+
+ static const float sqrt3_3 = sqrt(3) / 3;
+ static const float inv_sqrt6 = 1 / sqrt(6);
+ static const float inv_sqrt2 = 1 / sqrt(2);
+
+ /*! Functor for conversion from RGB to HSI color space.
+ **
+ ** \see f_rgb_to_hsl
+ */
+ template<unsigned inbits, unsigned outbits>
+ struct f_rgb_to_hsi
+ : public abstract::color_conversion<3, inbits, rgb_traits,
+ 3, outbits, hsi_traits, f_rgb_to_hsi<inbits, outbits> >
+ {
+ color<3, inbits, hsi_traits>
+ doit(const color<3, outbits, rgb_traits>& v) const
+ {
+ vec<3, float> in = v.to_float();
+ vec<3, float> out;
+ out[hsi_I] =
+ sqrt3_3 * in[rgb_R] + sqrt3_3 * in[rgb_G] + sqrt3_3 * in[rgb_B];
+ const float v1 = inv_sqrt2 * in[rgb_G] - inv_sqrt2 * in[rgb_B];
+ const float v2 = 2 * inv_sqrt6 * in[rgb_R] - inv_sqrt6 * in[rgb_G]
+ - inv_sqrt6 * in[rgb_B];
+ out[hsi_H] = atan2(v2, v1) / M_PI * 180.0;
+ if (out[hsi_H] < 0)
+ out[hsi_H] += 360.0;
+ assert(out[hsi_H] >= 0);
+ out[hsi_S] = sqrt(v1 * v1 + v2 * v2);
+ return out;
+ }
+
+ static std::string
+ name()
+ {
+ std::ostringstream s;
+ s << "f_rgb_to_hsi<" << inbits << ", " << outbits << '>';
+ s.str();
+ }
+ };
+
+ /*! Conversion from RGB to HSI color space.
+ **
+ ** \see f_rgb_to_hsl
+ */
+ template <unsigned inbits, unsigned outbits>
+ color<3, outbits, hsi_traits>
+ rgb_to_hsi(const color<3, inbits, rgb_traits>& v)
+ {
+ f_rgb_to_hsi<inbits, outbits> f;
+
+ return f(v);
+ }
+
+ /*! Functor conversion from HSI to RGB color space.
+ **
+ ** \see f_rgb_to_hsl
+ */
+ template<unsigned inbits, unsigned outbits>
+ struct f_hsi_to_rgb
+ : public abstract::color_conversion<3, inbits, hsi_traits,
+ 3, outbits, rgb_traits, f_hsi_to_rgb<inbits, outbits> >
+ {
+ color<3, outbits, rgb_traits>
+ doit(const color<3, inbits, hsi_traits>& v) const
+ {
+ vec<3, float> in = v.to_float();
+ vec<3, float> out;
+ const float h = in[hsi_H] / 180.0 * M_PI;
+ const float v1 = in[hsi_S] * cos(h);
+ const float v2 = in[hsi_S] * sin(h);
+ out[rgb_R] = sqrt3_3 * in[hsi_I] + 2 * inv_sqrt6 * v2;
+ out[rgb_G] = sqrt3_3 * in[hsi_I] + inv_sqrt2 * v1 - inv_sqrt6 * v2;
+ out[rgb_B] = sqrt3_3 * in[hsi_I] - inv_sqrt2 * v1 - inv_sqrt6 * v2;
+ return out;
+ }
+
+ static std::string
+ name()
+ {
+ std::ostringstream s;
+ s << "f_hsi_to_rgb<" << inbits << ", " << outbits << '>';
+ s.str();
+ }
+ };
+
+ /*! Conversion from HSI to RGB color space.
+ **
+ ** \see f_rgb_to_hsl
+ */
+ template <unsigned inbits, unsigned outbits>
+ color<3, outbits, rgb_traits>
+ hsi_to_rgb (const color<3, inbits, hsi_traits>& v)
+ {
+ f_hsi_to_rgb<inbits, outbits> f;
+
+ return f(v);
+ }
+
+ } // convert
+} // oln
+
+#endif // OLENA_CONVERT_RGBHSI_HH
Index: trunk/milena/sandbox/vigouroux/color.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/color.hh (revision 0)
+++ trunk/milena/sandbox/vigouroux/color.hh (revision 1707)
@@ -0,0 +1,44 @@
+// Copyright (C) 2001, 2002, 2003 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, 59 Temple Place - Suite 330, 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 NTG_COLOR_HH
+# define NTG_COLOR_HH
+
+/*
+ Proxy header for color types.
+*/
+
+# include <ntg/color/rgb.hh>
+# include <ntg/color/nrgb.hh>
+# include <ntg/color/hsi.hh>
+# include <ntg/color/hsl.hh>
+# include <ntg/color/hsv.hh>
+# include <ntg/color/xyz.hh>
+# include <ntg/color/yiq.hh>
+# include <ntg/color/yuv.hh>
+
+#endif // !NTG_COLOR_HH
Index: trunk/milena/sandbox/vigouroux/color/yiq.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/color/yiq.hh (revision 0)
+++ trunk/milena/sandbox/vigouroux/color/yiq.hh (revision 1707)
@@ -0,0 +1,64 @@
+// Copyright (C) 2001, 2002, 2003 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, 59 Temple Place - Suite 330, 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 NTG_COLOR_YIQ_HH
+# define NTG_COLOR_YIQ_HH
+
+# include <ntg/color/color.hh>
+
+namespace ntg
+{
+
+ enum yiq_comp
+ {
+ yiq_Y = 0,
+ yiq_I = 1,
+ yiq_Q = 2
+ };
+
+ template<unsigned icomp> struct yiq_traits;
+ template<> struct yiq_traits<yiq_Y> : public interval<0,1> {};
+
+ template<> struct yiq_traits<yiq_I>
+ {
+ static float lower_bound() { return -.4192; }
+ static float upper_bound() { return .5346; }
+ };
+
+ template<> struct yiq_traits<yiq_Q>
+ {
+ static float lower_bound() { return -.6783; }
+ static float upper_bound() { return .6527; }
+ };
+
+ typedef color<3,8,yiq_traits> yiq_8;
+ typedef color<3,16,yiq_traits> yiq_16;
+ typedef color<3,32,yiq_traits> yiq_32;
+
+} // end of ntg.
+
+#endif // !NTG_COLOR_YIQ_HH
Index: trunk/milena/sandbox/vigouroux/color/yuv.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/color/yuv.hh (revision 0)
+++ trunk/milena/sandbox/vigouroux/color/yuv.hh (revision 1707)
@@ -0,0 +1,63 @@
+// Copyright (C) 2001, 2002, 2003 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, 59 Temple Place - Suite 330, 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 NTG_COLOR_YUV_HH
+# define NTG_COLOR_YUV_HH
+
+# include <ntg/color/color.hh>
+
+namespace ntg
+{
+
+ enum yuv_comp
+ {
+ yuv_Y = 0,
+ yuv_U = 1,
+ yuv_V = 2
+ };
+
+ template<unsigned icomp> struct yuv_traits;
+ template<> struct yuv_traits<yuv_Y> : public interval<0,1> {};
+ template<> struct yuv_traits<yuv_U>
+ {
+ static float lower_bound() { return -0.517; }
+ static float upper_bound() { return 0.437; }
+ };
+
+ template<> struct yuv_traits<yuv_V>
+ {
+ static float lower_bound() { return -0.576; }
+ static float upper_bound() { return 0.654; }
+ };
+
+ typedef color<3,8,yuv_traits> yuv_8;
+ typedef color<3,16,yuv_traits> yuv_16;
+ typedef color<3,32,yuv_traits> yuv_32;
+
+} // end of ntg.
+
+#endif // !NTG_COLOR_YUV_HH
Index: trunk/milena/sandbox/vigouroux/color/hsi.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/color/hsi.hh (revision 0)
+++ trunk/milena/sandbox/vigouroux/color/hsi.hh (revision 1707)
@@ -0,0 +1,63 @@
+// Copyright (C) 2001, 2002, 2003 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, 59 Temple Place - Suite 330, 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 NTG_COLOR_HSI_HH
+# define NTG_COLOR_HSI_HH
+
+# include <ntg/color/color.hh>
+
+namespace ntg
+{
+
+ enum hsi_comp
+ {
+ hsi_H = 0,
+ hsi_S = 1,
+ hsi_I = 2
+ };
+
+ template<unsigned icomp> struct hsi_traits;
+ template<> struct hsi_traits<hsi_H> : public interval<0,360> {};
+ template<> struct hsi_traits<hsi_S>
+ {
+ static float lower_bound() { return 0.; }
+ static float upper_bound() { return 0.816497; } //2 / sqrt(6)
+ };
+
+ template<> struct hsi_traits<hsi_I>
+ {
+ static float lower_bound() { return 0.; }
+ static float upper_bound() { return 1.7320508; } //sqrt(3)
+ };
+
+ typedef color<3,8,hsi_traits> hsi_8;
+ typedef color<3,16,hsi_traits> hsi_16;
+ typedef color<3,32,hsi_traits> hsi_32;
+
+} // end of ntg.
+
+#endif // !NTG_COLOR_HSI_HH
Index: trunk/milena/sandbox/vigouroux/color/hsl.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/color/hsl.hh (revision 0)
+++ trunk/milena/sandbox/vigouroux/color/hsl.hh (revision 1707)
@@ -0,0 +1,54 @@
+// Copyright (C) 2001, 2002, 2003 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, 59 Temple Place - Suite 330, 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 NTG_COLOR_HSL_HH
+# define NTG_COLOR_HSL_HH
+
+# include <ntg/color/color.hh>
+
+namespace ntg
+{
+
+ enum hsl_comp
+ {
+ hsl_H = 0,
+ hsl_S = 1,
+ hsl_L = 2
+ };
+
+ template<unsigned icomp> struct hsl_traits;
+ template<> struct hsl_traits<hsl_H> : public interval<0,360> {};
+ template<> struct hsl_traits<hsl_S> : public interval<0,1> {};
+ template<> struct hsl_traits<hsl_L> : public interval<0,1> {};
+
+ typedef color<3,8,hsl_traits> hsl_8;
+ typedef color<3,16,hsl_traits> hsl_16;
+ typedef color<3,32,hsl_traits> hsl_32;
+
+} // end of ntg
+
+#endif // !NTG_COLOR_HSL_HH
Index: trunk/milena/sandbox/vigouroux/color/nrgb.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/color/nrgb.hh (revision 0)
+++ trunk/milena/sandbox/vigouroux/color/nrgb.hh (revision 1707)
@@ -0,0 +1,130 @@
+// Copyright (C) 2001, 2002, 2003 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, 59 Temple Place - Suite 330, 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 NTG_NRGB_HH
+# define NTG_NRGB_HH
+
+# include <ntg/color/color.hh>
+
+namespace ntg
+{
+
+ /*!
+ NTSC RGB format.
+ */
+
+ enum nrgb_comp
+ {
+ nrgb_R = 0,
+ nrgb_G = 1,
+ nrgb_B = 2
+ };
+
+ template<unsigned icomp> struct nrgb_traits;
+ template<>
+ struct nrgb_traits<nrgb_R>
+ {
+ static float lower_bound() { return 0;}
+ static float upper_bound() { return 1.0885004;}
+ };
+
+
+ template<>
+ struct nrgb_traits<nrgb_G>
+ {
+ static float lower_bound() { return -0.3321984;}
+ static float upper_bound() { return 1.3189264;}
+ };
+
+
+ template<>
+ struct nrgb_traits<nrgb_B>
+ {
+ static float lower_bound() { return -0.0688480;}
+ static float upper_bound() { return 0.904727;}
+ };
+
+
+ typedef color<3,8,nrgb_traits> nrgb_8;
+ typedef color<3,16,nrgb_traits> nrgb_16;
+ typedef color<3,32,nrgb_traits> nrgb_32;
+
+ // FIXME: not thread safe !
+# define DEFINE_COLOR(Type, Name, V1, V2, V3) \
+ inline const Type& Name() { \
+ static const Type tmp(V1, V2, V3); \
+ return tmp; \
+ }
+
+ namespace nrgb_8_color
+ {
+
+ DEFINE_COLOR(nrgb_8, white, 255, 255, 255)
+ DEFINE_COLOR(nrgb_8, gray, 128, 128, 128)
+ DEFINE_COLOR(nrgb_8, black, 0, 0, 0)
+ DEFINE_COLOR(nrgb_8, red, 255, 0, 0)
+ DEFINE_COLOR(nrgb_8, green, 0, 255, 0)
+ DEFINE_COLOR(nrgb_8, blue, 0, 0, 255)
+ DEFINE_COLOR(nrgb_8, yellow,255, 255, 0)
+ DEFINE_COLOR(nrgb_8, cyan, 0, 255, 255)
+ DEFINE_COLOR(nrgb_8, pink, 255, 0, 255)
+
+ } // end of nrgb_8_color
+
+ namespace nrgb_16_color
+ {
+
+ DEFINE_COLOR(nrgb_16, white, 255, 255, 255)
+ DEFINE_COLOR(nrgb_16, gray, 128, 128, 128)
+ DEFINE_COLOR(nrgb_16, black, 0, 0, 0)
+ DEFINE_COLOR(nrgb_16, red, 255, 0, 0)
+ DEFINE_COLOR(nrgb_16, green, 0, 255, 0)
+ DEFINE_COLOR(nrgb_16, blue, 0, 0, 255)
+ DEFINE_COLOR(nrgb_16, yellow,255, 255, 0)
+ DEFINE_COLOR(nrgb_16, cyan, 0, 255, 255)
+ DEFINE_COLOR(nrgb_16, pink, 255, 0, 255)
+
+ } // end of nrgb_16_color
+
+ namespace nrgb_32_color
+ {
+
+ DEFINE_COLOR(nrgb_32, white, 255, 255, 255)
+ DEFINE_COLOR(nrgb_32, gray, 128, 128, 128)
+ DEFINE_COLOR(nrgb_32, black, 0, 0, 0)
+ DEFINE_COLOR(nrgb_32, red, 255, 0, 0)
+ DEFINE_COLOR(nrgb_32, green, 0, 255, 0)
+ DEFINE_COLOR(nrgb_32, blue, 0, 0, 255)
+ DEFINE_COLOR(nrgb_32, yellow,255, 255, 0)
+ DEFINE_COLOR(nrgb_32, cyan, 0, 255, 255)
+ DEFINE_COLOR(nrgb_32, pink, 255, 0, 255)
+
+ } // end of nrgb_32_color.
+
+} // end of ntg.
+
+#endif // !NTG_COLOR_NRGB_HH
Index: trunk/milena/sandbox/vigouroux/color/xyz.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/color/xyz.hh (revision 0)
+++ trunk/milena/sandbox/vigouroux/color/xyz.hh (revision 1707)
@@ -0,0 +1,54 @@
+// Copyright (C) 2001, 2002, 2003 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, 59 Temple Place - Suite 330, 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 NTG_COLOR_XYZ_HH
+# define NTG_COLOR_XYZ_HH
+
+# include <ntg/color/color.hh>
+
+namespace ntg
+{
+
+ enum xyz_comp
+ {
+ xyz_X = 0,
+ xyz_Y = 1,
+ xyz_Z = 2
+ };
+
+ template<unsigned icomp> struct xyz_traits;
+ template<> struct xyz_traits<xyz_X> : public interval<0,1> {};
+ template<> struct xyz_traits<xyz_Y> : public interval<0,1> {};
+ template<> struct xyz_traits<xyz_Z> : public interval<0,1> {};
+
+ typedef color<3,8,xyz_traits> xyz_8;
+ typedef color<3,16,xyz_traits> xyz_16;
+ typedef color<3,32,xyz_traits> xyz_32;
+
+} // end of ntg.
+
+#endif // !NTG_COLOR_XYZ_HH
Index: trunk/milena/sandbox/vigouroux/color/rgb.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/color/rgb.hh (revision 0)
+++ trunk/milena/sandbox/vigouroux/color/rgb.hh (revision 1707)
@@ -0,0 +1,58 @@
+// Copyright (C) 2001, 2002, 2003 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, 59 Temple Place - Suite 330, 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 NTG_COLOR_RGB_HH
+# define NTG_COLOR_RGB_HH
+
+# include <ntg/color/color.hh>
+
+namespace ntg
+{
+
+ /*!
+ CIE RGB format.
+ */
+
+ enum rgb_comp
+ {
+ rgb_R = 0,
+ rgb_G = 1,
+ rgb_B = 2
+ };
+
+ template<unsigned icomp> struct rgb_traits;
+ template<> struct rgb_traits<rgb_R> : public interval<0,1> {};
+ template<> struct rgb_traits<rgb_G> : public interval<0,1> {};
+ template<> struct rgb_traits<rgb_B> : public interval<0,1> {};
+
+ typedef color<3,8,rgb_traits> rgb_8;
+ typedef color<3,16,rgb_traits> rgb_16;
+ typedef color<3,32,rgb_traits> rgb_32;
+
+} // end of ntg.
+
+#endif // !NTG_COLOR_RGB_HH
Index: trunk/milena/sandbox/vigouroux/color/color.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/color/color.hh (revision 0)
+++ trunk/milena/sandbox/vigouroux/color/color.hh (revision 1707)
@@ -0,0 +1,308 @@
+// Copyright (C) 2001, 2002, 2003, 2004 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, 59 Temple Place - Suite 330, 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 NTG_COLOR_COLOR_HH
+# define NTG_COLOR_COLOR_HH
+
+/*
+ Header for generic color type, from which real color types are defined.
+*/
+
+# include <ntg/basics.hh>
+# include <ntg/int.hh>
+# include <ntg/vect/vec.hh>
+# include <ntg/core/pred_succ.hh>
+
+# include <mlc/cmp.hh>
+
+# include <iostream>
+# include <sstream>
+# include <string>
+
+namespace ntg {
+
+ namespace internal {
+
+ /*------------------.
+ | typetraits<color> |
+ `------------------*/
+
+ template <unsigned ncomps,
+ unsigned qbits,
+ template <unsigned> class color_system>
+ struct typetraits<color<ncomps, qbits, color_system> >
+ {
+ enum { nb_comp = ncomps };
+
+ typedef color<ncomps, qbits, color_system> self;
+ typedef self ntg_type;
+ typedef vectorial abstract_type;
+ typedef int_u<qbits> comp_type;
+ typedef self base_type;
+ typedef vec<ncomps, int_u<qbits> > storage_type;
+ };
+
+ /*-------------------------.
+ | Helper structs for float |
+ `-------------------------*/
+
+ /*!
+ Helper struct to convert vec<N,T> to vec<N,float>,
+ taking color_system into account.
+ */
+ template <unsigned n,
+ unsigned ncomps,
+ unsigned qbits,
+ template <unsigned> class color_system>
+ struct _to_float
+ {
+ typedef int_u<qbits> T;
+ typedef vec<ncomps, T> in_type;
+ typedef vec<ncomps, float> out_type;
+
+ static void
+ doit (const in_type& in, out_type& out)
+ {
+ float in_range = float(ntg_max_val(T)) - float(ntg_min_val(T));
+ float out_range = float(color_system<n>::upper_bound())
+ - float(color_system<n>::lower_bound());
+ out[n] = ((float(in[n]) - float(ntg_min_val(T)))
+ * out_range / in_range
+ + float(color_system<n>::lower_bound()));
+
+ // process next componant recursively:
+ _to_float<n + 1, ncomps, qbits, color_system>::doit(in, out);
+ }
+ };
+
+ // Stop recursion when n == ncomps.
+ template <unsigned ncomps,
+ unsigned qbits,
+ template <unsigned> class color_system>
+ struct _to_float<ncomps, ncomps, qbits, color_system>
+ {
+ typedef vec<ncomps, int_u<qbits> > in_type;
+ typedef vec<ncomps, float> out_type;
+
+ static void
+ doit (const in_type&, out_type&)
+ {}
+ };
+
+ /*!
+ Helper struct to convert vec<N,float> to vec<N,T>,
+ taking color_system into account.
+ */
+ template <unsigned n,
+ unsigned ncomps,
+ unsigned qbits,
+ template <unsigned> class color_system>
+ struct _from_float
+ {
+ typedef int_u<qbits> T;
+ typedef vec<ncomps, float> in_type;
+ typedef vec<ncomps, T> out_type;
+
+ static void
+ doit (const in_type& in, out_type& out)
+ {
+ float out_range = float(optraits<T>::max())
+ - float(optraits<T>::min());
+ float in_range = float(color_system<n>::upper_bound())
+ - float(color_system<n>::lower_bound());
+
+ out[n] = cast::rbound<int_u<qbits> >
+ ((in[n] - float(color_system<n>::lower_bound()))
+ * out_range / in_range
+ + float(color_system<n>::lower_bound()));
+
+ // process next componant recursively:
+ _from_float<n + 1, ncomps, qbits, color_system>::doit(in, out);
+ }
+ };
+
+ // stop recursion when n == ncomps.
+ template <unsigned ncomps,
+ unsigned qbits,
+ template <unsigned> class color_system>
+ struct _from_float<ncomps, ncomps, qbits, color_system>
+ {
+ typedef vec<ncomps, float> in_type;
+ typedef vec<ncomps, int_u<qbits> > out_type;
+
+ static void
+ doit (const in_type&, out_type&)
+ {}
+ };
+
+ } // end of internal.
+
+ /*-----------------------------------.
+ | color<ncomps, qbits, color_system> |
+ `-----------------------------------*/
+
+ //! Generic type for color.
+ /*!
+ Specific color types (such as rgb, xyz, etc.) are defined by
+ specifying ncomps, qbits and a color_system trait.
+
+ ncomps: number of components.
+ qbits: number of bits of each unsigned integer component.
+ color_system: traits defining the intervals of each component.
+
+ Colors are implemented and seen as a vector of components.
+ */
+ template <unsigned ncomps,
+ unsigned qbits,
+ template <unsigned> class color_system>
+ struct color : public vect_value<color<ncomps, qbits, color_system> >
+ {
+ typedef int_u<qbits> comp_type;
+ typedef vec<ncomps, comp_type> vec_type;
+ typedef vec<ncomps, float> float_vec_type;
+
+ color() {};
+ color(const vec_type& vec) { this->val_ = vec; };
+ color(const float_vec_type& vec)
+ {
+ internal::_from_float<0,ncomps,qbits,color_system>::doit(vec,this->val_);
+ }
+
+ color(const comp_type& c1, const comp_type& c2, const comp_type& c3)
+ {
+ mlc::is_true<ncomps == 3>::ensure();
+ this->val_[0] = c1;
+ this->val_[1] = c2;
+ this->val_[2] = c3;
+ }
+
+ vec_type& as_vec() { return this->val_; }
+ const vec_type& as_vec() const { return this->val_; }
+
+ float_vec_type
+ to_float() const
+ {
+ float_vec_type tmp;
+ internal::_to_float<0,ncomps,qbits,color_system>::doit(this->val_, tmp);
+ return tmp;
+ }
+
+ bool
+ operator==(const color& r) const
+ { return this->val_ == r.val_; }
+ };
+
+ /*!
+ Helper function to complete color_system (by inheritance).
+ */
+ template<int lval, int uval>
+ struct interval
+ {
+ static int lower_bound() { return lval; }
+ static int upper_bound() { return uval; }
+ };
+
+ template <unsigned ncomps,
+ unsigned qbits,
+ template <unsigned> class color_system>
+ inline std::ostream&
+ operator<<(std::ostream& o,
+ const color<ncomps, qbits, color_system>& r)
+ {
+ o << r.as_vec();
+ return o;
+ }
+
+ namespace internal
+ {
+
+ /*----------------.
+ | optraits<color> |
+ `----------------*/
+
+ template <unsigned ncomps,
+ unsigned qbits,
+ template <unsigned> class color_system>
+ struct optraits<color<ncomps, qbits, color_system> >
+ {
+ private:
+ typedef color<ncomps, qbits, color_system> self;
+ typedef typename typetraits<self>::storage_type storage_type;
+
+ public:
+ static unsigned max_print_width ()
+ {
+ return ntg_max_print_width(storage_type);
+ }
+
+ static std::string
+ name()
+ {
+ std::ostringstream out;
+ // FIXME: Output color_system somehow.
+ out << "color<" << ncomps << "," << qbits << ",...>" << std::ends;
+ return out.str();
+ }
+ };
+
+
+ template <typename T> struct default_less;
+
+ /*! The specialized version of default_less for colors.
+ **
+ ** \warning This class is only provided to build classes
+ ** that need a less class, it does not correspond to
+ ** the reality. \n
+ ** Example of a std::set of RGB colors:
+ ** \verbatim
+ ** std::set<ntg:rgb_8,
+ ** ntg::internal::default_less<ntg::rgb8> > s;
+ ** s.insert(ntg::rgb_8(10, 16, 64));
+ ** \endverbatim
+ */
+ template <unsigned ncomps,
+ unsigned qbits,
+ template <unsigned> class color_system>
+ struct default_less< ntg::color<ncomps, qbits, color_system> >
+ {
+ typedef ntg::color<ncomps, qbits, color_system> arg_type;
+ bool operator()(const arg_type& l,
+ const arg_type& r) const
+ {
+ for (unsigned i = 0; i < ntg_nb_comp(arg_type); ++i)
+ if (l[i] < r[i])
+ return true;
+ else if (l[i] > r[i])
+ return false;
+ return false;
+ }
+ };
+ } // end of internal.
+
+} // end of ntg.
+
+#endif // !NTG_COLOR_COLOR_HH
Index: trunk/milena/sandbox/vigouroux/color/hsv.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/color/hsv.hh (revision 0)
+++ trunk/milena/sandbox/vigouroux/color/hsv.hh (revision 1707)
@@ -0,0 +1,55 @@
+// Copyright (C) 2001, 2002, 2003 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, 59 Temple Place - Suite 330, 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 NTG_COLOR_HSV_HH
+# define NTG_COLOR_HSV_HH
+
+# include <ntg/color/color.hh>
+
+namespace ntg
+{
+
+ enum hsv_comp
+ {
+ hsv_H = 0,
+ hsv_S = 1,
+ hsv_V = 2
+ };
+
+ template<unsigned icomp> struct hsv_traits;
+ template<> struct hsv_traits<hsv_H> : public interval<0,360> {};
+ template<> struct hsv_traits<hsv_S> : public interval<0,1> {};
+ template<> struct hsv_traits<hsv_V> : public interval<0,1> {};
+
+
+ typedef color<3,8,hsv_traits> hsv_8;
+ typedef color<3,16,hsv_traits> hsv_16;
+ typedef color<3,32,hsv_traits> hsv_32;
+
+} // end of ntg.
+
+#endif // !NTG_COLOR_HSV_HH
It seems ESIEE's mail server is preventing me from sending this
message today. So I'm sending it by hand. Hope it won't look too
much ugly, given the fact I'm sending it with Apple Mail (no troll
intended).
Hope ESIEE's mail server will return to a sound behavior soon, too...
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Add a new test on WST-based segmentation on a line graph image.
* tests/core/lena_line_graph_image_wst.cc: Rename and move...
* tests/morpho/lena_line_graph_image_wst1.cc: ...here.
Add more documentation.
Remove dead code.
* tests/morpho/lena_line_graph_image_wst2.cc: New test.
Based on tests/morpho/lena_line_graph_image_wst1.cc.
* tests/core/Makefile.am (check_PROGRAMS): Remove
lena_line_graph_image_wst.
(lena_line_graph_image_wst_SOURCES)
(lena_line_graph_image_wst_CXXFLAGS):
Remove.
* tests/morpho/Makefile.am (check_PROGRAMS): Add
lena_line_graph_image_wst1 and lena_line_graph_image_wst2.
(CXXFLAGS_SPEED): New.
Use it...
(meyer_wst_long_CXXFLAGS): ...here.
(lena_line_graph_image_wst1_SOURCES)
(lena_line_graph_image_wst1_CXXFLAGS)
(lena_line_graph_image_wst2_SOURCES)
(lena_line_graph_image_wst2_CXXFLAGS):
New.
* mln/core/line_graph_image.hh: More FIXME.
* tests/morpho/hit_or_miss.cc, tests/morpho/meyer_wst_long.cc:
Remove unnecessary #include's.
mln/core/line_graph_image.hh | 4 +
tests/core/Makefile.am | 5 -
tests/morpho/Makefile.am | 13 +++-
tests/morpho/hit_or_miss.cc | 1
tests/morpho/lena_line_graph_image_wst1.cc | 28 ++++++---
tests/morpho/lena_line_graph_image_wst2.cc | 84 +++++++++++++++++++
+---------
tests/morpho/meyer_wst_long.cc | 2
7 files changed, 94 insertions(+), 43 deletions(-)
Index: tests/morpho/lena_line_graph_image_wst1.cc
--- tests/morpho/lena_line_graph_image_wst1.cc (revision 1736)
+++ tests/morpho/lena_line_graph_image_wst1.cc (working copy)
@@ -25,8 +25,26 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/// \file tests/core/line_graph_image.cc
-/// \brief Tests on the Watershed Transform on a mln::line_graph_image.
+/* FIXME: We should factor as much things as possible between
+ tests/core/lena_line_graph_image_wst1.cc and
+ tests/core/lena_line_graph_image_wst2.cc, starting from conversion
+ routines. */
+
+/** \file tests/core/lena_line_graph_image_wst1.cc
+ \brief Tests on the Watershed Transform (WST) on a
mln::line_graph_image.
+
+ The scenario is as follows:
+ \li load a 2-D, gray-level image from a PGM file;
+ \li compute a morphological gradient of this image;
+ \li simplify the image to reduce the number of local minima;
+ \li convert this 2-D image into a line graph-based one, where
values
+ on edges are computed as the maxmimum of the values on the
nodes
+ adjacent to the edge;
+ \li perform a WST on the line graph image;
+ \li create an 2-D, color output image with height and width double
+ the size the original one, and copy the data of the input image
+ in it, interpolating inter-pixel points;
+ \li print the watershed on lines into that same image, and save
it. */
#include <vector>
@@ -44,7 +62,6 @@
#include <mln/morpho/meyer_wst.hh>
#include <mln/value/int_u8.hh>
-// #include <mln/value/int_u16.hh>
#include <mln/value/rgb8.hh>
#include <mln/literal/black.hh>
#include <mln/literal/colors.hh>
@@ -63,7 +80,6 @@
{
using namespace mln;
using value::int_u8;
-// using value::int_u16;
using value::rgb8;
/*--------.
@@ -72,7 +88,6 @@
typedef int_u8 input_val_t;
image2d<input_val_t> input;
-// io::pgm::load(input, MLN_IMG_DIR "/small.pgm");
io::pgm::load(input, MLN_IMG_DIR "/tiny.pgm");
/* FIXME: Don't compute a gradient on the image2d input. Instead,
@@ -85,7 +100,6 @@
// Simplify the input image.
image2d<input_val_t> work(input.domain());
-// morpho::closing_area(gradient, c4(), 50, work);
morpho::closing_area(gradient, c4(), 10, work);
/*-------------.
@@ -128,7 +142,6 @@
if (work.has(q))
{
g.add_edge(points[p], points[q]);
- // FIXME: Keep this valuation function?
edge_values.push_back(math::max(work(p), work(q)));
}
@@ -183,7 +196,6 @@
}
// Interpolate missing points in OUTPUT.
mln_piter_(output_t) p_out(output.domain());
-// mln_niter_(neighb2d) n_out(c4(), p_out);
for_all(p_out)
{
// Process points on even rows and odd columns
Index: tests/morpho/lena_line_graph_image_wst2.cc
--- tests/morpho/lena_line_graph_image_wst2.cc (revision 1736)
+++ tests/morpho/lena_line_graph_image_wst2.cc (working copy)
@@ -25,8 +25,32 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/// \file tests/core/line_graph_image.cc
-/// \brief Tests on the Watershed Transform on a mln::line_graph_image.
+/* FIXME: We should factor as much things as possible between
+ tests/core/lena_line_graph_image_wst1.cc and
+ tests/core/lena_line_graph_image_wst2.cc, starting from conversion
+ routines. */
+
+/** \file tests/core/lena_line_graph_image_wst2.cc
+ \brief More tests on the Watershed Transform (WST) on a
+ mln::line_graph_image.
+
+
+ The scenario is as follows:
+ \li load a 2-D, gray-level image from a PGM file;
+ \li simplify the image to reduce the number of local minima;
+ \li convert this 2-D image into a line graph-based one, where
values
+ on edges are computed as the absolute value f the difference
+ between the values on the nodes adjacent to the edge, so as to
+ create a (norm of the gradient) ``between the pixels'' of the
+ input image;
+ \li (insert an minima-killer pass here, as soon as it works on
+ graph-based images);
+ \li perform a WST on the line graph image;
+ \li reduce the quantification of the result of the WST;
+ \li create an 2-D, color output image with height and width double
+ the size the original one, and copy the data of the input image
+ in it, interpolating inter-pixel points;
+ \li print the watershed on lines into that same image, and save
it. */
#include <vector>
@@ -42,9 +66,10 @@
#include <mln/morpho/gradient.hh>
#include <mln/morpho/closing_area.hh>
#include <mln/morpho/meyer_wst.hh>
+#include <mln/level/stretch.hh>
#include <mln/value/int_u8.hh>
-// #include <mln/value/int_u16.hh>
+#include <mln/value/int_u16.hh>
#include <mln/value/rgb8.hh>
#include <mln/literal/black.hh>
#include <mln/literal/colors.hh>
@@ -63,7 +88,7 @@
{
using namespace mln;
using value::int_u8;
-// using value::int_u16;
+ using value::int_u16;
using value::rgb8;
/*--------.
@@ -72,21 +97,15 @@
typedef int_u8 input_val_t;
image2d<input_val_t> input;
-// io::pgm::load(input, MLN_IMG_DIR "/small.pgm");
- io::pgm::load(input, MLN_IMG_DIR "/tiny.pgm");
+ io::pgm::load(input, MLN_IMG_DIR "/small.pgm");
- /* FIXME: Don't compute a gradient on the image2d input. Instead,
- have the values of the line graph image /behaves/ as the gradient
- of the input, i.e., edges should hold the absolute difference
- between gray levels.
- */
- image2d<input_val_t> gradient =
- morpho::gradient (input, convert::to_window(c4()));
+ /* FIXME: In fact, we'd probably want to compute the gradient
+ /before/ simplfying the image, but as the area closing doesn't
+ work (yet) on graph images, hence we cannot do this yet. */
// Simplify the input image.
image2d<input_val_t> work(input.domain());
-// morpho::closing_area(gradient, c4(), 50, work);
- morpho::closing_area(gradient, c4(), 10, work);
+ morpho::closing_area(input, c8(), 500, work);
/*-------------.
| Line graph. |
@@ -105,7 +124,7 @@
util::node_id id = 0;
// Nodes.
- std::vector<int> node_values;
+ std::vector<input_val_t> node_values;
mln_fwd_piter_(image2d<input_val_t>) p(work.domain());
for_all (p)
{
@@ -121,26 +140,32 @@
// Edges.
window2d next_c4_win;
next_c4_win.insert(0, 1).insert(1, 0);
- std::vector<int> edge_values;
+ std::vector<input_val_t> edge_values;
mln_fwd_qiter_(window2d) q(next_c4_win, p);
for_all (p)
for_all (q)
if (work.has(q))
{
g.add_edge(points[p], points[q]);
- // FIXME: Keep this valuation function?
- edge_values.push_back(math::max(work(p), work(q)));
+ // The computed value is a kind of norm of the gradient
+ // bewteen P and Q.
+ edge_values.push_back(math::abs(work(p) - work(q)));
}
// Line graph point set.
p_line_graph<point2d> plg(g);
// Line graph image.
- /* FIXME: Shouldn't we use `input_val_t' instead of plain `int' as
value
- type here? */
- typedef line_graph_image<point2d, int> ima_t;
+ typedef line_graph_image<point2d, input_val_t> ima_t;
ima_t lg_ima(plg, node_values, edge_values);
+ /*-----------------.
+ | Simplification. |
+ `-----------------*/
+
+ // FIXME: Adjust the area closing filter, so that we can apply it on
+ // graph images.
+
/*------.
| WST. |
`------*/
@@ -149,11 +174,20 @@
nbh_t nbh;
// Perform a Watershed Transform.
+ typedef int_u16 wst_full_val_t;
+ wst_full_val_t nbasins;
+ typedef line_graph_image<point2d, wst_full_val_t> wst_full_ima_t;
+ wst_full_ima_t wshed_full = morpho::meyer_wst(lg_ima, nbh, nbasins);
+ std::cout << "nbasins = " << nbasins << std::endl;
+
+ // Reduce the value set to 8-bit.
typedef int_u8 wst_val_t;
- wst_val_t nbasins;
typedef line_graph_image<point2d, wst_val_t> wst_ima_t;
- wst_ima_t wshed = morpho::meyer_wst(lg_ima, nbh, nbasins);
- std::cout << "nbasins = " << nbasins << std::endl;
+ // FIXME: Initializations should not be that complicated.
+ wst_ima_t wshed (plg,
+ std::vector<wst_val_t>(node_values.size()),
+ std::vector<wst_val_t>(edge_values.size()));
+ level::stretch(wshed_full, wshed);
/*---------.
| Output. |
Index: tests/core/Makefile.am
--- tests/core/Makefile.am (revision 1736)
+++ tests/core/Makefile.am (working copy)
@@ -10,7 +10,6 @@
initialize \
graph_elt_window \
graph_image \
- lena_line_graph_image_wst \
line_graph_elt_window \
line_graph_image \
line_graph_image_wst \
@@ -52,8 +51,4 @@
t_image_SOURCES = t_image.cc
tr_image_SOURCES = tr_image.cc
-# FIXME: We should isolate this test, as it takes a long time.
-lena_line_graph_image_wst_SOURCES = lena_line_graph_image_wst.cc
-lena_line_graph_image_wst_CXXFLAGS = -O3 -ggdb
-
TESTS = $(check_PROGRAMS)
Index: tests/morpho/Makefile.am
--- tests/morpho/Makefile.am (revision 1736)
+++ tests/morpho/Makefile.am (working copy)
@@ -12,6 +12,8 @@
gradient \
hit_or_miss \
laplacian \
+ lena_line_graph_image_wst1 \
+ lena_line_graph_image_wst2 \
meyer_wst \
meyer_wst_long \
opening_area \
@@ -33,8 +35,15 @@
thinning_SOURCES = thinning.cc
meyer_wst_SOURCES = meyer_wst.cc
-# FIXME: We should isolate this test, as it takes a long time.
+
+# FIXME: We should isolate those tests, as they take a long time to
+# execute.
+CXXFLAGS_SPEED = -O3 -ggdb
+lena_line_graph_image_wst1_SOURCES = lena_line_graph_image_wst1.cc
+lena_line_graph_image_wst1_CXXFLAGS = $(CXXFLAGS_SPEED)
+lena_line_graph_image_wst2_SOURCES = lena_line_graph_image_wst2.cc
+lena_line_graph_image_wst2_CXXFLAGS = $(CXXFLAGS_SPEED)
meyer_wst_long_SOURCES = meyer_wst_long.cc
-meyer_wst_long_CXXFLAGS = -O3 -ggdb
+meyer_wst_long_CXXFLAGS = $(CXXFLAGS_SPEED)
TESTS = $(check_PROGRAMS)
Index: mln/core/line_graph_image.hh
--- mln/core/line_graph_image.hh (revision 1736)
+++ mln/core/line_graph_image.hh (working copy)
@@ -191,6 +191,10 @@
| Initialization. |
`-----------------*/
+ /* FIXME: We should check the expected behavior of init_ here. As
+ far as I (Roland) can recall, it was not meant to initialize
+ data/values. We should probably just create vectors of values of
+ the same size, not copy the values. */
template <typename P, typename V>
inline
void init_(tag::image_t,
Index: tests/morpho/hit_or_miss.cc
--- tests/morpho/hit_or_miss.cc (revision 1736)
+++ tests/morpho/hit_or_miss.cc (working copy)
@@ -41,7 +41,6 @@
#include <mln/io/pbm/load.hh>
#include <mln/io/pbm/save.hh>
#include <mln/level/fill.hh>
-#include <mln/level/stretch.hh>
#include <mln/morpho/hit_or_miss.hh>
Index: tests/morpho/meyer_wst_long.cc
--- tests/morpho/meyer_wst_long.cc (revision 1736)
+++ tests/morpho/meyer_wst_long.cc (working copy)
@@ -35,8 +35,6 @@
#include <mln/core/window2d.hh>
#include <mln/core/neighb2d.hh>
-#include <mln/level/stretch.hh>
-
#include <mln/value/int_u8.hh>
#include <mln/value/int_u16.hh>
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2008-02-18 Michel Pellegrin <pellegrin(a)lrde.epita.fr>
Work on conditional inheritance done.
* sandbox/pellegrin/cond_inheritance: Folder containing my work.
* sandbox/pellegrin/cond_inheritance/Makefile: Compile the test.
* sandbox/pellegrin/cond_inheritance/concept: New.
* sandbox/pellegrin/cond_inheritance/concept/point_set.hh: New.
* sandbox/pellegrin/cond_inheritance/internal: New.
* sandbox/pellegrin/cond_inheritance/internal/multi_set.hh: New.
* sandbox/pellegrin/cond_inheritance/internal/point_set_base.hh: New.
* sandbox/pellegrin/cond_inheritance/internal/uni_set.hh: New.
* sandbox/pellegrin/cond_inheritance/p_array.hh: Definition of a
p_array.
* sandbox/pellegrin/cond_inheritance/p_set.hh: Definition of a p_set.
* sandbox/pellegrin/cond_inheritance/test_cond_inherit.cc: Test file.
---
Makefile | 26 ++++++++++++
concept/point_set.hh | 72 +++++++++++++++++++++++++++++++++
internal/multi_set.hh | 72 +++++++++++++++++++++++++++++++++
internal/point_set_base.hh | 97 +++++++++++++++++++++++++++++++++++++++++++++
internal/uni_set.hh | 70 ++++++++++++++++++++++++++++++++
p_array.hh | 72 +++++++++++++++++++++++++++++++++
p_set.hh | 72 +++++++++++++++++++++++++++++++++
test_cond_inherit.cc | 61 ++++++++++++++++++++++++++++
8 files changed, 542 insertions(+)
Index: trunk/milena/sandbox/pellegrin/cond_inheritance/test_cond_inherit.cc
===================================================================
--- trunk/milena/sandbox/pellegrin/cond_inheritance/test_cond_inherit.cc (revision 0)
+++ trunk/milena/sandbox/pellegrin/cond_inheritance/test_cond_inherit.cc (revision 1736)
@@ -0,0 +1,61 @@
+// 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.
+
+/*! \file sandbox/pellegrin/cond_inheritance/test_cond_inherit.cc
+ *
+ * \brief test my work on conditional inheritance.
+ */
+
+#include <iostream>
+#include <string>
+#include <mln/core/image2d.hh>
+#include <mln/io/pgm/load.hh>
+
+#include "p_set.hh"
+#include "p_array.hh"
+
+
+int main ()
+{
+ //const std::string file ("../../../img/lena.pgm");
+ //mln::image2d<mln::value::int_u8> I = mln::io::pgm::load (file);
+ //mln::image2d<mln::value::int_u8>::fwd_piter p (I.domain ());
+
+ //for_all (p)
+ //{
+ //}
+ std::cout << __FILE__ << ": construction d'un objet p_array<int>"
+ << std::endl;
+ mln::p_array<int> int_array;
+
+ std::cout << '\n' << __FILE__ << ": construction d'un objet p_set<int>"
+ << std::endl;
+ mln::p_set<int> int_set;
+
+ std::cout << "\nEnd of test on conditional inheritance" << std::endl;
+}
+
Index: trunk/milena/sandbox/pellegrin/cond_inheritance/p_set.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/cond_inheritance/p_set.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/cond_inheritance/p_set.hh (revision 1736)
@@ -0,0 +1,72 @@
+// 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 P_SET_HH
+# define P_SET_HH
+
+/*! \file sandbox/pellegrin/cond_inheritance/p_set.hh
+ *
+ * \brief Definition of p_set class.
+ */
+
+# include "internal/point_set_base.hh"
+
+
+namespace mln
+{
+
+ /*! \brief Point set class.
+ *
+ * This is a mathematical uni-set of points. The
+ * parameter \p P shall be a Point type.
+ *
+ * \todo All.
+ */
+ template <typename E>
+ class p_set: public internal::point_set_base<p_set<E>, E>
+ {
+ public:
+ p_set ();
+ };
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename E>
+ inline
+ p_set<E>::p_set ()
+ {
+ std::cout << " " << __FILE__ << ": constructeur mln::p_set<E>"
+ << std::endl;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! P_SET_HH
Index: trunk/milena/sandbox/pellegrin/cond_inheritance/concept/point_set.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/cond_inheritance/concept/point_set.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/cond_inheritance/concept/point_set.hh (revision 1736)
@@ -0,0 +1,72 @@
+// 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 POINT_SET_HH
+# define POINT_SET_HH
+
+/*! \file sandbox/pellegrin/cond_inheritance/concept/point_set.hh
+ *
+ * \brief Definition of point_set class.
+ */
+
+# include <iostream>
+# include <vector>
+
+
+namespace mln
+{
+ namespace concept
+ {
+ /*! \brief Point set class.
+ */
+ template <typename E>
+ class point_set
+ {
+ std::vector<E> data;
+ protected:
+ point_set ();
+ };
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename E>
+ inline
+ point_set<E>::point_set ()
+ {
+ std::cout << " " << __FILE__
+ << ": constructeur mln::concept::point_set<E>" << std::endl;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace concept
+
+} // end of namespace mln
+
+
+#endif // ! POINT_SET_HH
Index: trunk/milena/sandbox/pellegrin/cond_inheritance/p_array.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/cond_inheritance/p_array.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/cond_inheritance/p_array.hh (revision 1736)
@@ -0,0 +1,72 @@
+// 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 P_ARRAY_HH
+# define P_ARRAY_HH
+
+/*! \file sandbox/pellegrin/cond_inheritance/p_array.hh
+ *
+ * \brief Definition of p_array class.
+ */
+
+# include "internal/point_set_base.hh"
+
+
+namespace mln
+{
+
+ /*! \brief Point set class.
+ *
+ * This is a mathematical multi-set of points. The
+ * parameter \p P shall be a Point type.
+ *
+ * \todo All.
+ */
+ template <typename E>
+ class p_array : public internal::point_set_base<p_array<E>, E>
+ {
+ public:
+ p_array ();
+ };
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename E>
+ inline
+ p_array<E>::p_array ()
+ {
+ std::cout << " " << __FILE__ << ": constructeur mln::p_array<E>"
+ << std::endl;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! P_ARRAY_HH
Index: trunk/milena/sandbox/pellegrin/cond_inheritance/internal/multi_set.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/cond_inheritance/internal/multi_set.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/cond_inheritance/internal/multi_set.hh (revision 1736)
@@ -0,0 +1,72 @@
+// 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 MULTI_SET_HH
+# define MULTI_SET_HH
+
+/*! \file sandbox/pellegrin/cond_inheritance/internal/multi_set.hh
+ *
+ * \brief Definition of multi_set class.
+ */
+
+# include <iostream>
+
+# include "concept/point_set.hh"
+
+
+namespace mln
+{
+ namespace internal
+ {
+ /*! \brief Multi set class.
+ */
+ template <typename E>
+ class multi_set: public concept::point_set<E>
+ {
+ protected:
+ multi_set ();
+ };
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename E>
+ inline
+ multi_set<E>::multi_set ()
+ {
+ std::cout << " " << __FILE__
+ << ": constructeur mln::internal::multi_set<E>" << std::endl;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace internal
+
+} // end of namespace mln
+
+
+#endif // ! MULTI_SET_HH
Index: trunk/milena/sandbox/pellegrin/cond_inheritance/internal/uni_set.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/cond_inheritance/internal/uni_set.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/cond_inheritance/internal/uni_set.hh (revision 1736)
@@ -0,0 +1,70 @@
+// 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 UNI_SET_HH
+# define UNI_SET_HH
+
+/*! \file sandbox/pellegrin/cond_inheritance/internal/uni_set.hh
+ *
+ * \brief Definition of uni_set class.
+ */
+
+# include "concept/point_set.hh"
+
+
+namespace mln
+{
+ namespace internal
+ {
+ /*! \brief Uni set class.
+ */
+ template <typename E>
+ class uni_set: public concept::point_set<E>
+ {
+ protected:
+ uni_set ();
+ };
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename E>
+ inline
+ uni_set<E>::uni_set ()
+ {
+ std::cout << " " << __FILE__
+ << ": constructeur mln::internal::uni_set<E>" << std::endl;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace internal
+
+} // end of namespace mln
+
+
+#endif // ! UNI_SET_HH
Index: trunk/milena/sandbox/pellegrin/cond_inheritance/internal/point_set_base.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/cond_inheritance/internal/point_set_base.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/cond_inheritance/internal/point_set_base.hh (revision 1736)
@@ -0,0 +1,97 @@
+// 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 POINT_SET_BASE_HH
+# define POINT_SET_BASE_HH
+
+/*! \file sandbox/pellegrin/cond_inheritance/internal/point_set_base.hh
+ *
+ * \brief Definition of point_set_base class.
+ */
+
+# include "internal/uni_set.hh"
+# include "internal/multi_set.hh"
+
+
+namespace mln
+{
+ // fwd declaration
+ template <typename E>
+ class p_set;
+ template <typename E>
+ class p_array;
+
+ namespace internal
+ {
+ /*! \brief Point set base class.
+ */
+ template <typename T, typename E>
+ class point_set_base;
+
+ template <typename E>
+ class point_set_base<p_set<E>, E>: public uni_set<E>
+ {
+ protected:
+ point_set_base ();
+ };
+
+ template <typename E>
+ class point_set_base<p_array<E>, E>: public multi_set<E>
+ {
+ protected:
+ point_set_base ();
+ };
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename E>
+ inline
+ point_set_base<p_set<E>, E>::point_set_base ()
+ {
+ std::cout << " " << __FILE__
+ << ": constructeur mln::internal::point_set_base<p_set<E>, E>"
+ << std::endl;
+ }
+
+ template <typename E>
+ inline
+ point_set_base<p_array<E>, E>::point_set_base ()
+ {
+ std::cout << " " << __FILE__
+ << ": constructeur "
+ "mln::internal::point_set_base<p_array<E>, E>"
+ << std::endl;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace internal
+
+} // end of namespace mln
+
+#endif // ! POINT_SET_BASE_HH
Index: trunk/milena/sandbox/pellegrin/cond_inheritance/Makefile
===================================================================
--- trunk/milena/sandbox/pellegrin/cond_inheritance/Makefile (revision 0)
+++ trunk/milena/sandbox/pellegrin/cond_inheritance/Makefile (revision 1736)
@@ -0,0 +1,26 @@
+All_warnings = -ansi -pedantic -Wabi -Wctor-dtor-privacy -Wnon-virtual-dtor \
+ -Wreorder -Weffc++ -Wno-deprecated -Wstrict-null-sentinel \
+ -Wno-non-template-friend -Wold-style-cast -Woverloaded-virtual \
+ -Wno-pmf-conversions -Wsign-promo -fsyntax-only-pedantic-errors \
+ -w -Wextra -Wall -Waddress -Waggregate-return -Wno-attributes \
+ -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment -Wconversion \
+ -Wno-deprecated-declarations -Wdisabled-optimization -Wno-div-by-zero \
+ -Wno-endif-labels -Werror -Wfatal-errors -Wfloat-equal -Wformat \
+ -Wformat=2 -Wno-format-extra-args -Wformat-nonliteral \
+ -Wformat-security -Wformat-y2k -Wimplicit -Wimport -Wno-import \
+ -Winit-self -Winline -Wno-invalid-offsetof -Winvalid-pch \
+ -Wlarger-than-1 -Wunsafe-loop-optimizations -Wlong-long \
+ -Wmissing-braces -Wmissing-field-initializers \
+ -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn \
+ -Wno-multichar -Wno-overflow -Woverlength-strings -Wpacked -Wpadded \
+ -Wparentheses -Wpointer-arith -Wredundant-decls -Wreturn-type \
+ -Wsequence-point -Wshadow -Wsign-compare -Wstack-protector \
+ -Wstrict-aliasing -Wstrict-overflow -Wswitch -Wswitch-default \
+ -Wswitch-enum -Wsystem-headers -Wtrigraphs -Wundef -Wuninitialized \
+ -Wunknown-pragmas -Wno-pragmas -Wunreachable-code -Wunused \
+ -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value \
+ -Wunused-variable -Wvariadic-macros -Wvolatile-register-var \
+ -Wwrite-strings \
+
+all:
+ g++-4.2 -ansi -pedantic -I../../.. -I. test_cond_inherit.cc -o test