* tests/accu/bbox.cc: update doc.
* tests/fun/v2v/Makefile.am,
* tests/fun/v2v/hsl_to_rgb.cc,
* tests/fun/v2v/rgb_to_hsl.cc: new tests.
* tests/io/magick/Makefile.am: add specific ldflags.
* tests/morpho/attribute/card.cc,
* tests/morpho/attribute/height.cc,
* tests/morpho/attribute/volume.cc: avoid warnings.
---
milena/ChangeLog | 16 ++++
milena/tests/accu/bbox.cc | 10 +-
milena/tests/fun/v2v/Makefile.am | 6 +-
.../attribute/volume.cc => fun/v2v/hsl_to_rgb.cc} | 35 ++++++--
milena/tests/fun/v2v/rgb_hsi_conversion.cc | 95 --------------------
.../attribute/volume.cc => fun/v2v/rgb_to_hsl.cc} | 41 ++++++---
milena/tests/morpho/attribute/card.cc | 2 +-
milena/tests/morpho/attribute/height.cc | 8 +-
milena/tests/morpho/attribute/volume.cc | 2 +-
9 files changed, 87 insertions(+), 128 deletions(-)
copy milena/tests/{morpho/attribute/volume.cc => fun/v2v/hsl_to_rgb.cc} (66%)
delete mode 100644 milena/tests/fun/v2v/rgb_hsi_conversion.cc
copy milena/tests/{morpho/attribute/volume.cc => fun/v2v/rgb_to_hsl.cc} (62%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index bf45e27..06ccdcd 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,21 @@
2009-05-15 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+ Fix tests.
+
+ * tests/accu/bbox.cc: update doc.
+
+ * tests/fun/v2v/Makefile.am,
+ * tests/fun/v2v/hsl_to_rgb.cc,
+ * tests/fun/v2v/rgb_to_hsl.cc: new tests.
+
+ * tests/io/magick/Makefile.am: add specific ldflags.
+
+ * tests/morpho/attribute/card.cc,
+ * tests/morpho/attribute/height.cc,
+ * tests/morpho/attribute/volume.cc: avoid warnings.
+
+2009-05-15 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
Fix a bug in util::pix.
* mln/util/pix.hh: Do not store a const reference of a psite, but a
diff --git a/milena/tests/accu/bbox.cc b/milena/tests/accu/bbox.cc
index 8b911f5..b7cb411 100644
--- a/milena/tests/accu/bbox.cc
+++ b/milena/tests/accu/bbox.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,9 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/accu/nil.cc
- *
- * \brief Tests on mln::accu::nil.
- */
+/// \file tests/accu/nil.cc
+///
+/// Tests on mln::accu::nil.
#include <mln/core/alias/point2d.hh>
diff --git a/milena/tests/fun/v2v/Makefile.am b/milena/tests/fun/v2v/Makefile.am
index 9627a2d..a01be1c 100644
--- a/milena/tests/fun/v2v/Makefile.am
+++ b/milena/tests/fun/v2v/Makefile.am
@@ -3,14 +3,16 @@
include $(top_srcdir)/milena/tests/tests.mk
check_PROGRAMS = \
+ hsl_to_rgb \
norm \
projection \
- rgb_hsi_conversion \
+ rgb_to_hsl \
wrap
norm_SOURCES = norm.cc
projection_SOURCES = projection.cc
-rgb_hsi_conversion_SOURCES = rgb_hsi_conversion.cc
+rgb_to_hsl_SOURCES = rgb_to_hsl.cc
+hsl_to_rgb_SOURCES = hsl_to_rgb.cc
wrap_SOURCES = wrap.cc
TESTS = $(check_PROGRAMS)
diff --git a/milena/tests/morpho/attribute/volume.cc b/milena/tests/fun/v2v/hsl_to_rgb.cc
similarity index 66%
copy from milena/tests/morpho/attribute/volume.cc
copy to milena/tests/fun/v2v/hsl_to_rgb.cc
index 9360fec..0f02e28 100644
--- a/milena/tests/morpho/attribute/volume.cc
+++ b/milena/tests/fun/v2v/hsl_to_rgb.cc
@@ -25,24 +25,41 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/// \file tests/morpho/attribute/volume.cc
+/// \file tests/fun/v2v/hsl_to_rgb.cc
///
-/// Test on mln::morpho::attribute::volume.
+/// Test HSL-to-RGB conversion.
#include <mln/core/image/image2d.hh>
-#include <mln/morpho/attribute/volume.hh>
+#include <mln/fun/v2v/hsl_to_rgb.hh>
+
+#include <mln/level/compare.hh>
+#include <mln/level/transform.hh>
+
+#include <mln/value/hsl.hh>
+#include <mln/value/rgb8.hh>
+
+#include <mln/debug/println.hh>
+
+using mln::value::rgb8;
+using mln::value::hsl_f;
+
+rgb8 ref[][2] = { { rgb8(0,0,0), rgb8(255,255,255) },
+ { rgb8(128,128,128), rgb8(90,90, 90) } };
+
+hsl_f dat[][2] = { { hsl_f(0,0,0), hsl_f(0,0,255) },
+ { hsl_f(0,0,128), hsl_f(0,0,90) } };
int main()
{
using namespace mln;
- typedef image2d<int> I;
- I ima(3, 3);
+ image2d<rgb8> ref_ima = make::image(ref);
+ image2d<hsl_f> ima = make::image(dat);
- util::pix<I> px(ima, point2d(0,0));
+ image2d<value::rgb8> ima_rgb = level::transform(ima,
+ fun::v2v::f_hsl_to_rgb_3x8);
- morpho::attribute::volume<I> v;
- v.take(px);
- mln_assertion(v == 1);
+ mln_assertion(ima_rgb == ref_ima);
}
+
diff --git a/milena/tests/fun/v2v/rgb_hsi_conversion.cc
b/milena/tests/fun/v2v/rgb_hsi_conversion.cc
deleted file mode 100644
index f760fa1..0000000
--- a/milena/tests/fun/v2v/rgb_hsi_conversion.cc
+++ /dev/null
@@ -1,95 +0,0 @@
-// Copyright (C) 2008 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/fun/v2v/rgb_hsi_conversion.cc
-///
-/// Test RGB-to-HSI conversion.
-
-#include <cmath>
-
-#include <mln/value/hsi.hh>
-#include <mln/fun/v2v/rgb_to_hsi.hh>
-
-#include <mln/core/image/image2d.hh>
-#include <mln/value/rgb8.hh>
-
-#include <mln/io/ppm/load.hh>
-#include <mln/io/ppm/save.hh>
-#include <mln/math/round.hh>
-#include <mln/level/transform.hh>
-
-#include "tests/data.hh"
-
-
-template <typename I1, typename I2>
-float rms(const mln::Image<I1>& ima1_, const mln::Image<I2>& ima2_)
-{
- const I1& ima1 = exact(ima1_);
- const I2& ima2 = exact(ima2_);
-
- mln_precondition(ima1.is_valid() && ima2.is_valid());
-
- double sum = 0, nb = 0;
-
- mln_piter(I1) p(ima1.domain());
- for_all(p)
- {
- mln_value(I1) c1 = ima1(p);
- mln_value(I2) c2 = ima2(p);
- double
- distred = c2.red() - c1.red(),
- distgreen = c2.green() - c1.green(),
- distblue = c2.blue() - c1.blue();
-
- ++nb;
- sum += distred * distred + distblue * distblue + distgreen * distgreen;
- }
-
- if (nb == 0)
- return 0;
-
- return std::sqrt(sum / nb);
-}
-
-
-int main()
-{
- using namespace mln;
-
- image2d<value::rgb8> lena;
- io::ppm::load(lena, MLN_IMG_DIR "/lena.ppm");
-
- image2d<value::hsi_f> lena_hsi = level::transform(lena,
- fun::v2v::f_rgb_to_hsi_f);
-
- image2d<value::rgb8> lena_rgb = level::transform(lena_hsi,
- fun::v2v::f_hsi_to_rgb_3x8);
-
- double err = rms(lena, lena_rgb);
- std::cout << "err: " << err << std::endl;
-}
-
diff --git a/milena/tests/morpho/attribute/volume.cc b/milena/tests/fun/v2v/rgb_to_hsl.cc
similarity index 62%
copy from milena/tests/morpho/attribute/volume.cc
copy to milena/tests/fun/v2v/rgb_to_hsl.cc
index 9360fec..45d6d77 100644
--- a/milena/tests/morpho/attribute/volume.cc
+++ b/milena/tests/fun/v2v/rgb_to_hsl.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// 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
@@ -25,24 +26,42 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/// \file tests/morpho/attribute/volume.cc
+/// \file tests/fun/v2v/rgb_to_hsl.cc
///
-/// Test on mln::morpho::attribute::volume.
+/// Test RGB-to-HSL conversion.
#include <mln/core/image/image2d.hh>
-#include <mln/morpho/attribute/volume.hh>
+#include <mln/value/hsl.hh>
+#include <mln/value/rgb8.hh>
+
+#include <mln/fun/v2v/rgb_to_hsl.hh>
+
+#include <mln/level/compare.hh>
+#include <mln/level/transform.hh>
+
+#include <mln/make/image.hh>
+
+#include <mln/debug/println.hh>
+
+using mln::value::rgb8;
+using mln::value::hsl_f;
+
+rgb8 dat[][2] = { { rgb8(0,0,0), rgb8(255,255,255) },
+ { rgb8(128,128,128), rgb8(90,90, 90) } };
+
+hsl_f ref[][2] = { { hsl_f(0,0,0), hsl_f(0,0,255) },
+ { hsl_f(0,0,128), hsl_f(0,0,90) } };
int main()
{
using namespace mln;
- typedef image2d<int> I;
- I ima(3, 3);
+ image2d<value::rgb8> ima = make::image(dat);
+ image2d<hsl_f> ref_ima = make::image(ref);
+ image2d<hsl_f> ima_hsl = level::transform(ima,
+ fun::v2v::f_rgb_to_hsl_f);
- util::pix<I> px(ima, point2d(0,0));
-
- morpho::attribute::volume<I> v;
- v.take(px);
- mln_assertion(v == 1);
+ mln_assertion(ima_hsl == ref_ima);
}
+
diff --git a/milena/tests/morpho/attribute/card.cc
b/milena/tests/morpho/attribute/card.cc
index afdaaaf..6bc5b4e 100644
--- a/milena/tests/morpho/attribute/card.cc
+++ b/milena/tests/morpho/attribute/card.cc
@@ -46,5 +46,5 @@ int main()
c.take();
c.take(p);
c.take(px);
- mln_assertion(c == 3);
+ mln_assertion(c == 3u);
}
diff --git a/milena/tests/morpho/attribute/height.cc
b/milena/tests/morpho/attribute/height.cc
index 4b2a2d0..63be89e 100644
--- a/milena/tests/morpho/attribute/height.cc
+++ b/milena/tests/morpho/attribute/height.cc
@@ -44,7 +44,7 @@ int main()
for (int i = 0; i < 5; i++)
accu.take(t[i]);
- mln_assertion(accu.to_result() == 7);
+ mln_assertion(accu.to_result() == 7u);
A accu2;
@@ -54,9 +54,9 @@ int main()
accu.take(t[i] + 2);
accu2.take(t[i] - 2);
}
- mln_assertion(accu.to_result() == 7);
- mln_assertion(accu2.to_result() == 7);
+ mln_assertion(accu.to_result() == 7u);
+ mln_assertion(accu2.to_result() == 7u);
accu.take(accu2);
- mln_assertion(accu.to_result() == 11);
+ mln_assertion(accu.to_result() == 11u);
}
diff --git a/milena/tests/morpho/attribute/volume.cc
b/milena/tests/morpho/attribute/volume.cc
index 9360fec..3bb8af2 100644
--- a/milena/tests/morpho/attribute/volume.cc
+++ b/milena/tests/morpho/attribute/volume.cc
@@ -44,5 +44,5 @@ int main()
morpho::attribute::volume<I> v;
v.take(px);
- mln_assertion(v == 1);
+ mln_assertion(v == 1u);
}
--
1.5.6.5