---
.../green => milena}/mln/fun/v2v/rgb8_to_rgbn.hh | 82 +++++++++-----------
scribo/ChangeLog | 6 ++
2 files changed, 42 insertions(+), 46 deletions(-)
copy {scribo/sandbox/green => milena}/mln/fun/v2v/rgb8_to_rgbn.hh (61%)
diff --git a/scribo/sandbox/green/mln/fun/v2v/rgb8_to_rgbn.hh
b/milena/mln/fun/v2v/rgb8_to_rgbn.hh
similarity index 61%
copy from scribo/sandbox/green/mln/fun/v2v/rgb8_to_rgbn.hh
copy to milena/mln/fun/v2v/rgb8_to_rgbn.hh
index acf1b5e..f1f3611 100644
--- a/scribo/sandbox/green/mln/fun/v2v/rgb8_to_rgbn.hh
+++ b/milena/mln/fun/v2v/rgb8_to_rgbn.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008, 2009, 2010 EPITA LRDE
+// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -23,9 +23,10 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef MLN_FUN_V2V_RGB8_TO_RGBN_HH
+#ifndef MLN_FUN_V2V_RGB8_TO_RGBN_HH
# define MLN_FUN_V2V_RGB8_TO_RGBN_HH
+# include <mln/core/concept/function.hh>
# include <mln/value/rgb8.hh>
# include <mln/value/rgb.hh>
# include <mln/core/contract.hh>
@@ -33,36 +34,6 @@
/// \file
///
/// \brief Convert rgb8 value to rgbn, n < 8.
-///
-/// The source implements the reduction of quantification for any size less 8.
-///
-/// The following sample is a typical use of the histogram.
-///
-/// #include <mln/accu/stat/histo3d_rgb.hh>
-/// #include <mln/core/image/image2d.hh>
-/// #include <mln/core/image/image3d.hh>
-/// #include <mln/data/compute.hh>
-/// #include <mln/data/transform.hh>
-/// #include <mln/fun/v2v/rgb8_to_rgbn.hh>
-/// #include <mln/img_path.hh>
-/// #include <mln/io/ppm/load.hh>
-/// #include <mln/value/rgb.hh>
-/// #include <mln/value/rgb8.hh>
-///
-/// int main()
-/// {
-/// typedef mln::value::rgb8 t_rgb8;
-/// typedef mln::value::rgb<7> t_rgb7;
-/// mln::image2d<t_rgb8> img_rgb8;
-/// mln::image2d<t_rgb7> img_rgb7;
-/// mln::image3d<unsigned> histo;
-///
-/// mln::io::ppm::load(img_rgb8, OLENA_IMG_PATH"/lena.ppm");
-/// img_rgb7 =mln::data::transform(img_rgb8,mln::fun::v2v::rgb8_to_rgbn<7>());
-/// histo = mln::data::compute(mln::accu::meta::stat::histo3d_rgb(),img_rgb7);
-///
-/// return 0;
-/// }
namespace mln
@@ -74,11 +45,13 @@ namespace mln
namespace v2v
{
+
/// \brief Convert a rgb8 value to a rgn, n < 8.
///
- /// Param n defines the output quantification used for the transformation.
+ /// \param n defines the output quantification used for the transformation.
///
/// \ingroup modfunv2v
+ //
template <unsigned n>
struct rgb8_to_rgbn : Function_v2v< rgb8_to_rgbn<n> >
{
@@ -91,29 +64,46 @@ namespace mln
///
/// Conversion is done by computing the size by which we
/// divide each rgb component.
+ //
+ result operator()(const argument& c) const;
+
+ };
+
- result operator()(const argument& c) const
- {
- mln_precondition(8 > n);
+# ifndef MLN_INCLUDE_ONLY
- unsigned size = pow(2,(8-n));
- /*
+ /// \brief Convert a rgb8 value to a rgn, n < 8.
+ ///
+ /// \param n defines the output quantification used for the transformation.
+ ///
+ /// \ingroup modfunv2v
+ //
+ template <unsigned n>
+ typename rgb8_to_rgbn<n>::result
+ rgb8_to_rgbn<n>::operator()(const argument& c) const
+ {
+ mln_precondition(8 > n);
+
+ unsigned size = pow(2,(8-n));
+ /*
std::cout << "c : " << c << std::endl;
std::cout << "red : " << c.red() << std::endl;
std::cout << "size : " << size << std::endl;
std::cout << "res : " << (c.red() / size) << std::endl;
std::cout << "max : " <<
(mln_max(mln::value::int_u<n>))<< std::endl;
- */
- result res(c.red() / size, c.green() / size, c.blue() / size);
+ */
+ result res(c.red() / size, c.green() / size, c.blue() / size);
+
+ return res;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
- return res;
- }
- };
- }
+ } // end of namespace mln::fun::v2v
- }
+ } // end of namespace mln::fun
-}
+} // end of namespace mln
#endif // ! MLN_FUN_V2V_RGB8_TO_RGBN_HH
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index e0d155a..cd8db5d 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,11 @@
2010-11-15 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Import rgb8 to rgbn conversion function from Yann's sandbox.
+
+ * mln/fun/v2v/rgb8_to_rgbn.hh: New.
+
+2010-11-15 Guillaume Lazzara <z(a)lrde.epita.fr>
+
* scribo/core/macros.hh: Remove deprecated macro.
2010-09-02 Guillaume Lazzara <z(a)lrde.epita.fr>
--
1.5.6.5