
* mln/binarization/binarization.hh: remove a non-valid static test. * mln/value/rgb16.hh, * mln/fun/v2b/threshold.hh, * mln/binarization/threshold.hh: update comments. * mln/debug/colorize.hh: make it work with rgb16. * mln/value/rgb8.hh: remove useless include. * tests/core/image/Makefile.am, * tests/core/image/tr_image.cc: re-enable tr_image test and make it work. --- milena/ChangeLog | 18 +++++++++ milena/mln/binarization/binarization.hh | 32 ++++++++-------- milena/mln/binarization/threshold.hh | 38 +++++++++---------- milena/mln/debug/colorize.hh | 15 ++++--- milena/mln/fun/v2b/threshold.hh | 19 ++++----- milena/mln/value/rgb16.hh | 18 ++++---- milena/mln/value/rgb8.hh | 19 ++++----- milena/tests/core/image/Makefile.am | 6 +- milena/tests/core/image/tr_image.cc | 63 +++++++++++++++++++------------ 9 files changed, 128 insertions(+), 100 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index 6f6463d..b2b7dd9 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,23 @@ 2009-01-06 Guillaume Lazzara <z@lrde.epita.fr> + Small fixes. + + * mln/binarization/binarization.hh: remove a non-valid static test. + + * mln/value/rgb16.hh, + * mln/fun/v2b/threshold.hh, + * mln/binarization/threshold.hh: update comments. + + * mln/debug/colorize.hh: make it work with rgb16. + + * mln/value/rgb8.hh: remove useless include. + + * tests/core/image/Makefile.am, + * tests/core/image/tr_image.cc: re-enable tr_image test and make it + work. + +2009-01-06 Guillaume Lazzara <z@lrde.epita.fr> + Update tutorial. * doc/Doxyfile.in: Add a new IMAGE_PATH and a new macro expansion in diff --git a/milena/mln/binarization/binarization.hh b/milena/mln/binarization/binarization.hh index a333ef2..1a6f2d7 100644 --- a/milena/mln/binarization/binarization.hh +++ b/milena/mln/binarization/binarization.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2008 EPITA Research and Development Laboratory +// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -28,10 +29,9 @@ #ifndef MLN_BINARIZATION_BINARIZATION_HH # define MLN_BINARIZATION_BINARIZATION_HH -/*! \file mln/binarization/threshold.hh - * - * \brief Threshold the contents of an image into another binary one. - */ +/// \file mln/binarization/threshold.hh +/// +/// Threshold the contents of an image into another binary one. # include <mln/core/concept/function.hh> # include <mln/level/transform.hh> @@ -43,20 +43,19 @@ namespace mln namespace binarization { - /*! Thresholds the values of \p input so that they can be stored in - * the \p output binary image. - * - * \param[in] input The input image. - * \param[in] fun The thresholding function, from value(I) to bool. - * - * for_all(p), output(p) = fun(p) - * - */ + /// Thresholds the values of \p input so that they can be stored in + /// the \p output binary image. + /// + /// \param[in] input The input image. + /// \param[in] fun The thresholding function, from value(I) to bool. + /// + /// for_all(p), output(p) = fun(p) template <typename I, typename F> inline mln_concrete_ch_value(I, bool) binarization(const Image<I>& input, const Function_v2b<F>& fun); + # ifndef MLN_INCLUDE_ONLY namespace impl @@ -79,6 +78,9 @@ namespace mln } // end of namespace mln::binarization::impl + + // Facade + template <typename I, typename F> inline mln_concrete_ch_value(I, bool) @@ -86,8 +88,6 @@ namespace mln { trace::entering("binarization::binarization"); mln_precondition(exact(input).is_valid()); - mlc_is(mln_trait_value_nature(mln_value(I)), - trait::value::nature::scalar)::check(); mln_concrete_ch_value(I, bool) output(exact(input).domain()); output = impl::binarization_(exact(input), fun); diff --git a/milena/mln/binarization/threshold.hh b/milena/mln/binarization/threshold.hh index 104d40e..f76cd8a 100644 --- a/milena/mln/binarization/threshold.hh +++ b/milena/mln/binarization/threshold.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2008 EPITA Research and Development Laboratory +// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -28,10 +29,9 @@ #ifndef MLN_BINARIZATION_THRESHOLD_HH # define MLN_BINARIZATION_THRESHOLD_HH -/*! \file mln/binarization/threshold.hh - * - * \brief Threshold the contents of an image into another binary one. - */ +/// \file mln/binarization/threshold.hh +/// +/// Threshold the contents of an image into another binary one. # include <mln/binarization/binarization.hh> # include <mln/fun/v2b/threshold.hh> @@ -43,21 +43,19 @@ namespace mln namespace binarization { - /*! Thresholds the values of \p input so that they can be stored in - * the \p output binary image. - * - * \param[in] input The input image. - * \param[in] threshold The threshold. - * - * If input(p) is greater or equal than the threshold, the - * value in the output image in the same point will be TRUE, else FALSE. - * - */ + /// Thresholds the values of \p input so that they can be stored in + /// the \p output binary image. + /// + /// \param[in] input The input image. + /// \param[in] threshold The threshold. + /// + /// If input(p) is greater or equal than the threshold, the + /// value in the output image in the same point will be TRUE, else FALSE. template <typename I> mln_concrete_ch_value(I, bool) threshold(const Image<I>& input, const mln_value(I) threshold); - + # ifndef MLN_INCLUDE_ONLY template <typename I> @@ -66,18 +64,18 @@ namespace mln threshold(const Image<I>& input, const mln_value(I) threshold_value) { trace::entering("binarization::threshold"); - + mln_precondition(exact(input).is_valid()); mlc_is(mln_trait_value_nature(mln_value(I)), trait::value::nature::scalar)::check(); mln_concrete_ch_value(I, bool) output(exact(input).domain()); - + // FIXME : threshold value should be a percentage. fun::v2b::threshold< mln_value(I) > f(threshold_value); - + output = binarization::binarization(exact(input), f); - + trace::exiting("binarization::threshold"); return output; } diff --git a/milena/mln/debug/colorize.hh b/milena/mln/debug/colorize.hh index 544a755..44021ec 100644 --- a/milena/mln/debug/colorize.hh +++ b/milena/mln/debug/colorize.hh @@ -85,14 +85,15 @@ namespace mln { template <typename V> - V random_color(); + V random_color(const V&); - mln::value::rgb8 - random_color() + template <unsigned n> + mln::value::rgb<n> + random_color(const mln::value::rgb<n>&) { - return mln::value::rgb8(colorize_::min_value + (rand() % colorize_::max_value), - colorize_::min_value + (rand() % colorize_::max_value), - colorize_::min_value + (rand() % colorize_::max_value)); + return mln::value::rgb<n>(colorize_::min_value + (rand() % colorize_::max_value), + colorize_::min_value + (rand() % colorize_::max_value), + colorize_::min_value + (rand() % colorize_::max_value)); } } @@ -125,7 +126,7 @@ namespace mln f(0) = literal::black; } for (; i < f.size(); ++i) - f(i) = internal::random_color(); + f(i) = internal::random_color(value); } mln_assertion(f.size() >= (label_count)); mln_ch_value(L, V) output = level::transform(input, f); diff --git a/milena/mln/fun/v2b/threshold.hh b/milena/mln/fun/v2b/threshold.hh index c8ea02c..85b7831 100644 --- a/milena/mln/fun/v2b/threshold.hh +++ b/milena/mln/fun/v2b/threshold.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2008 EPITA Research and Development Laboratory +// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -28,10 +29,9 @@ #ifndef MLN_FUN_V2B_THRESHOLD_HH # define MLN_FUN_V2B_THRESHOLD_HH -/*! \file mln/fun/v2b/threshold.hh - * - * \brief FIXME. - */ +/// \file mln/fun/v2b/threshold.hh +/// +/// FIXME. # include <mln/core/concept/function.hh> @@ -45,11 +45,8 @@ namespace mln namespace v2b { - /*! - *\brief Threshold function. - * f(v) = (v >= threshold). - * - */ + /// Threshold function. + /// f(v) = (v >= threshold). template <typename V> struct threshold : public Function_v2b< threshold<V> > { @@ -75,7 +72,7 @@ namespace mln bool threshold<V>::operator()(const V& v) const { - return (v >= a); + return v >= a; } # endif // ! MLN_INCLUDE_ONLY diff --git a/milena/mln/value/rgb16.hh b/milena/mln/value/rgb16.hh index 1a22013..a012aa0 100644 --- a/milena/mln/value/rgb16.hh +++ b/milena/mln/value/rgb16.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2009 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -28,11 +29,10 @@ #ifndef MLN_VALUE_RGB16_HH # define MLN_VALUE_RGB16_HH -/*! \file mln/value/rgb16.hh - * - * \brief Color class for red-green-blue where every component is - * 16-bit encoded. - */ +/// \file mln/value/rgb16.hh +/// +/// Color class for red-green-blue where every component is +/// 16-bit encoded. # include <mln/value/rgb.hh> @@ -43,10 +43,10 @@ namespace mln namespace value { - /*! \brief Color class for red-green-blue where every component is - * 16-bit encoded. - */ + /// Color class for red-green-blue where every component is + /// 16-bit encoded. typedef rgb<16> rgb16; + } // end of namespace mln::value } // end of namespace mln diff --git a/milena/mln/value/rgb8.hh b/milena/mln/value/rgb8.hh index e31df55..25a2c9a 100644 --- a/milena/mln/value/rgb8.hh +++ b/milena/mln/value/rgb8.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2009 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -28,14 +29,12 @@ #ifndef MLN_VALUE_RGB8_HH # define MLN_VALUE_RGB8_HH -/*! \file mln/value/rgb8.hh - * - * \brief Color class for red-green-blue where every component is - * 8-bit encoded. - */ +/// \file mln/value/rgb8.hh +/// +/// Color class for red-green-blue where every component is +/// 8-bit encoded. # include <mln/value/rgb.hh> -# include <mln/value/int_u8.hh> namespace mln @@ -44,10 +43,10 @@ namespace mln namespace value { - /*! \brief Color class for red-green-blue where every component is - * 8-bit encoded. - */ + /// Color class for red-green-blue where every component is + /// 8-bit encoded. typedef rgb<8> rgb8; + } // end of namespace mln::value } // end of namespace mln diff --git a/milena/tests/core/image/Makefile.am b/milena/tests/core/image/Makefile.am index 72f0c93..1faaaf5 100644 --- a/milena/tests/core/image/Makefile.am +++ b/milena/tests/core/image/Makefile.am @@ -26,8 +26,8 @@ check_PROGRAMS = \ safe_image \ ## sparse_image \ sub_image \ - t_image -## tr_image + t_image \ + tr_image ## value_enc_image noinst_HEADERS = complex_image.hh @@ -55,7 +55,7 @@ safe_image_SOURCES = safe_image.cc ##sparse_image_SOURCES = sparse_image.cc sub_image_SOURCES = sub_image.cc t_image_SOURCES = t_image.cc -##tr_image_SOURCES = tr_image.cc +tr_image_SOURCES = tr_image.cc ##value_enc_image_SOURCES = value_enc_image.cc # Tests depending on the FreeImagePlus library. diff --git a/milena/tests/core/image/tr_image.cc b/milena/tests/core/image/tr_image.cc index 90b2b9f..804a6a3 100644 --- a/milena/tests/core/image/tr_image.cc +++ b/milena/tests/core/image/tr_image.cc @@ -1,4 +1,5 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2009 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -25,10 +26,10 @@ // reasons why the executable file might be covered by the GNU General // Public License. -/*! \file tests/core/image/tr_image.cc - * - * \brief Tests on mln::tr_image. - */ +/// \file tests/core/image/tr_image.cc +/// +/// Tests on mln::tr_image. +/// FIXME: write a real test! #include <iostream> @@ -44,28 +45,42 @@ int main() using namespace mln; using value::int_u8; - image3d<int_u8> in(3, 3, 3); - image3d<int_u8> out(in.domain()); + { + image2d<int_u8> in(3, 3); - debug::iota(in); - debug::println(in); + debug::iota(in); + debug::println(in); - fun::x2x::rotation<3, float> rot1(1.67, literal::zero); + algebra::vec<2, float> v; + v[0] = 0; + v[1] = 1; + fun::x2x::rotation<2, float> rot1(1.67, v); - tr_image<mln_pset_(image3d<int_u8>), - image3d<int_u8>, - fun::x2x::rotation<3, float> > - inter(out.domain(), in, rot1); + tr_image<mln_pset_(image2d<int_u8>), + image2d<int_u8>, + fun::x2x::rotation<2, float> > + inter(in.domain(), in, rot1); - image3d<int_u8>::fwd_piter p(out.domain()); + debug::println(inter); + } - for_all(p) - { - algebra::vec<3, int> vec = p.to_site().to_vec(); - if (inter.has(p)) - out(p) = inter(vec); - else - out(p) = 255; - } - debug::println(out); + { + image3d<int_u8> in(3, 3, 3); + + debug::iota(in); + debug::println(in); + + algebra::vec<3, float> v; + v[0] = 0; + v[1] = 0; + v[2] = 1; + fun::x2x::rotation<3, float> rot1(1.67, v); + + tr_image<mln_pset_(image3d<int_u8>), + image3d<int_u8>, + fun::x2x::rotation<3, float> > + inter(in.domain(), in, rot1); + + debug::println(inter); + } } -- 1.5.6.5
participants (1)
-
Guillaume Lazzara