* mln/debug/colorize.hh: move...
* mln/labeling/colorize.hh: ... here.
* tests/labeling/Makefile.am,
* tests/labeling/colorize.cc: add a new test.
---
milena/ChangeLog | 10 +++++
milena/mln/{debug => labeling}/colorize.hh | 40 ++++++++++++++++---
milena/tests/labeling/Makefile.am | 2 +
milena/tests/labeling/colorize.cc | 56 ++++++++++++++++++++++++++++
4 files changed, 101 insertions(+), 7 deletions(-)
rename milena/mln/{debug => labeling}/colorize.hh (80%)
create mode 100644 milena/tests/labeling/colorize.cc
diff --git a/milena/ChangeLog b/milena/ChangeLog
index c69383e..4430b6c 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,13 @@
+2009-05-07 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
+ Move debug::colorize to labeling::colorize.
+
+ * mln/debug/colorize.hh: move...
+ * mln/labeling/colorize.hh: ... here.
+
+ * tests/labeling/Makefile.am,
+ * tests/labeling/colorize.cc: add a new test.
+
2009-05-07 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Several fixes and new stuff.
diff --git a/milena/mln/debug/colorize.hh b/milena/mln/labeling/colorize.hh
similarity index 80%
rename from milena/mln/debug/colorize.hh
rename to milena/mln/labeling/colorize.hh
index 4f492bf..49b1f63 100644
--- a/milena/mln/debug/colorize.hh
+++ b/milena/mln/labeling/colorize.hh
@@ -29,7 +29,7 @@
#ifndef MLN_DEBUG_COLORIZE_HH
# define MLN_DEBUG_COLORIZE_HH
-/// \file mln/debug/colorize.hh
+/// \file mln/labeling/colorize.hh
///
/// Fill an image with successive values.
@@ -38,12 +38,14 @@
# include <mln/value/rgb8.hh>
# include <mln/literal/black.hh>
# include <mln/level/transform.hh>
+# include <mln/level/compute.hh>
+# include <mln/accu/max.hh>
namespace mln
{
- namespace debug
+ namespace labeling
{
namespace colorize_
@@ -58,8 +60,8 @@ namespace mln
/*!
* litera::black is used for component 0, e.g. the background.
* Min and max values for RGB values can be set through the global
- * variables mln::debug::colorize_::min_value and
- * mln::debug::colorize_::max_value.
+ * variables mln::labeling::colorize_::min_value and
+ * mln::labeling::colorize_::max_value.
*
* \param[in] value value type used in the returned image.
* \param[in] labeled_image A labeled image (\sa labeling::blobs).
@@ -72,6 +74,12 @@ namespace mln
const mln_value(L)& nlabels);
+ template <typename V, typename L>
+ mln_ch_value(L, V)
+ colorize(const V& value,
+ const Image<L>& labeled_image);
+
+
# ifndef MLN_INCLUDE_ONLY
namespace colorize_
@@ -105,7 +113,7 @@ namespace mln
const Image<L>& input,
const mln_value(L)& nlabels)
{
- trace::entering("debug::colorize");
+ trace::entering("labeling::colorize");
mln_precondition(exact(input).is_valid());
// FIXME: check that V is a color type.
// FIXME: we want to be sure that this is a label.
@@ -132,13 +140,31 @@ namespace mln
mln_assertion(f.size() >= (label_count));
mln_ch_value(L, V) output = level::transform(input, f);
- trace::exiting("debug::colorize");
+ trace::exiting("labeling::colorize");
+ return output;
+ }
+
+ template <typename V, typename L>
+ inline
+ mln_ch_value(L, V)
+ colorize(const V& value,
+ const Image<L>& input)
+ {
+ trace::entering("labeling::colorize");
+ mln_precondition(exact(input).is_valid());
+
+ accu::max<mln_value(L)> accu;
+ mln_value(L) nlabels = level::compute(accu, input);
+
+ mln_ch_value(L,V) output = colorize(value, input, nlabels);
+
+ trace::exiting("labeling::colorize");
return output;
}
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace mln::debug
+ } // end of namespace mln::labeling
} // end of namespace mln
diff --git a/milena/tests/labeling/Makefile.am b/milena/tests/labeling/Makefile.am
index 411674e..0dfb121 100644
--- a/milena/tests/labeling/Makefile.am
+++ b/milena/tests/labeling/Makefile.am
@@ -5,6 +5,7 @@ include $(top_srcdir)/milena/tests/tests.mk
check_PROGRAMS = \
background \
blobs \
+ colorize \
compute \
fill_holes \
flat_zones \
@@ -20,6 +21,7 @@ check_PROGRAMS = \
background_SOURCES = background.cc
blobs_SOURCES = blobs.cc
+colorize_SOURCES = colorize.cc
compute_SOURCES = compute.cc
fill_holes_SOURCES = fill_holes.cc
flat_zones_SOURCES = flat_zones.cc
diff --git a/milena/tests/labeling/colorize.cc b/milena/tests/labeling/colorize.cc
new file mode 100644
index 0000000..e424473
--- /dev/null
+++ b/milena/tests/labeling/colorize.cc
@@ -0,0 +1,56 @@
+// Copyright (C) 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
+// 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 tests/labeling/colorize.cc
+///
+/// Test on mln::labeling::colorize.
+
+# include <mln/make/image.hh>
+# include <mln/value/rgb8.hh>
+# include <mln/value/int_u8.hh>
+# include <mln/labeling/colorize.hh>
+# include <mln/level/compare.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ value::int_u8 values[][2] = { { 3, 3 },
+ { 0, 0 } };
+
+ typedef value::rgb8 rgb_t;
+ value::rgb8 ref_data[][2] = { { rgb_t(89,92,86), rgb_t(89,92,86) },
+ { rgb_t(0,0,0), rgb_t(0,0,0) } };
+
+ image2d<value::int_u8> ima = make::image(values);
+ image2d<rgb_t> ref = make::image(ref_data);
+
+ image2d<value::rgb8> ima_color = labeling::colorize(value::rgb8(), ima);
+
+ mln_assertion(ref == ima_color);
+}
--
1.6.1.2