Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
May 2009
- 11 participants
- 312 discussions
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-05-07 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Fixed watershed, now works on edges.
* fabien/igr/Makefile.rules: Optimization flag is now -O1.
* fabien/igr/seg_fixed.cc: Fixed 'float' bug on edges.
---
TODO | 7 +-
igr/Makefile.rules | 2
igr/seg_fixed.cc | 171 +++++++++++++++++++++++++++++++++++++++++++++++++----
3 files changed, 167 insertions(+), 13 deletions(-)
Index: trunk/milena/sandbox/fabien/igr/seg_fixed.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/seg_fixed.cc (revision 3772)
+++ trunk/milena/sandbox/fabien/igr/seg_fixed.cc (revision 3773)
@@ -5,34 +5,53 @@
#include <mln/core/alias/neighb2d.hh>
#include <mln/core/image/image3d.hh>
#include <mln/core/image/slice_image.hh>
+#include <mln/core/image/image_if.hh>
#include <mln/core/routine/duplicate.hh>
+#include <mln/core/routine/extend.hh>
+#include <mln/core/var.hh>
#include <mln/io/dump/all.hh>
#include <mln/io/pgm/save.hh>
+#include <mln/io/ppm/save.hh>
#include <mln/value/int_u8.hh>
#include <mln/value/int_u12.hh>
#include <mln/value/label_16.hh>
+#include <mln/value/rgb8.hh>
+#include <mln/value/float01_8.hh>
#include <mln/accu/sum.hh>
#include <mln/data/fill.hh>
+#include <mln/data/paste.hh>
#include <mln/debug/quiet.hh>
#include <mln/convert/from_to.hh>
#include <mln/level/compute.hh>
#include <mln/level/stretch.hh>
+#include <mln/make/image2d.hh>
+#include <mln/math/diff_abs.hh>
+#include <mln/morpho/dilation.hh>
+#include <mln/morpho/erosion.hh>
#include <mln/morpho/closing/volume.hh>
+#include <mln/morpho/elementary/gradient.hh>
#include <mln/morpho/watershed/flooding.hh>
+#include <mln/pw/all.hh>
#include <mln/util/array.hh>
#include <mln/world/inter_pixel/display_edge.hh>
+#include <mln/world/inter_pixel/compute.hh>
+#include <mln/world/inter_pixel/immerse.hh>
#include <mln/world/inter_pixel/neighb2d.hh>
-#include <mln/world/inter_pixel/dim2/is_edge.hh>
+#include <mln/world/inter_pixel/is_pixel.hh>
+
+#include <mln/debug/colorize.hh>
+#include <mln/debug/println.hh>
using namespace mln;
using value::int_u8;
using value::int_u12;
using value::label_16;
+using value::float01_8;
@@ -77,7 +96,7 @@
else
res = 0.f;
- //std::cout << "dist: " << res << std::endl;
+ res = res;
return 1 - res;
}
@@ -132,6 +151,67 @@
}
+// Dummy.
+///////////////////////////////////////////////////////////////////////////////
+template <typename I, typename N>
+inline
+image2d<int>
+dummy_dist_on_edges(const I& input, const N& nbh)
+{
+ image2d<int> output;
+ initialize(output, input);
+ data::fill(output, 0);
+
+ mln_piter(I) p(input.domain());
+ mln_niter(N) n(nbh, p);
+ for_all(p)
+ {
+ n.start();
+ int c1 = input(n);
+ n.next();
+ int c2 = input(n);
+ output(p) = math::diff_abs(c1, c2);
+ }
+
+ return output;
+}
+
+
+
+// Distance function.
+//-------------------
+
+struct dist_t : Function_vv2v<dist_t>
+{
+ typedef float result;
+
+ template <typename V>
+ float operator()(util::array<V> v1, util::array<V> v2) const
+ {
+ float res = 0.f;
+
+ for (unsigned i = 0; i < v1.nelements(); ++i)
+ res += std::min(v1[i], v2[i]);
+
+ image1d<V> tmp_ima;
+ accu::sum<V> accu_sum;
+
+ convert::from_to(v1, tmp_ima);
+ float sum_v1 = level::compute(accu_sum, tmp_ima);
+
+ convert::from_to(v2, tmp_ima);
+ float sum_v2 = level::compute(accu_sum, tmp_ima);
+
+ res /= std::max(sum_v1, sum_v2);
+
+ return 1 - res;
+ }
+} dist;
+
+
+
+
+
@@ -146,10 +226,12 @@
if (argc != 3)
return usage(argv[0]);
+
// Initialization.
image3d<int_u12> input;
io::dump::load(input, argv[1]);
- image2d<util::array<int_u12> > ima_arr;
+ typedef image2d<util::array<int_u12> > I;
+ I ima_arr;
initialize(ima_arr, slice(input, 0));
for (unsigned int i = 0; i < input.nslices(); ++i)
{
@@ -159,23 +241,92 @@
ima_arr(p).append(tmp_slice(p));
}
- // Edges computation.
- image2d<float> edges = dist_on_edges(ima_arr);
+ // Edges image creation.
+ //image2d<float> edges = dist_on_edges(ima_arr);
+ typedef image_if<I, world::inter_pixel::is_pixel> Ix;
+ Ix imax = world::inter_pixel::immerse(ima_arr);
+
+ // Edges distance computation.
+ mln_VAR(edges, world::inter_pixel::compute(imax, dist));
+
+ {
// Display.
- image2d<float> display_ima = world::inter_pixel::display_edge(edges, 0.0, 3);
+ mln_VAR(display_ima, world::inter_pixel::display_edge(edges.unmorph_(), 0.0, 3));
io::pgm::save(level::stretch(int_u8(), display_ima), "edges.pgm");
+ }
+
+ // Save edges.
+ //mln_VAR(e, edges.unmorph_());
+ //data::fill((e | (!world::inter_pixel::is_separator())).rw(), nbasins.next());
+ //io::pgm::save(level::stretch(int_u8(), edges.unmorph_()), "edges_raw.pgm");
+
+ mln_VAR(e, level::stretch(int_u8(), edges));
+
+ {
+ // Display.
+ mln_VAR(display_ima, world::inter_pixel::display_edge(e.unmorph_(), 0.0, 3));
+ io::pgm::save(level::stretch(int_u8(), display_ima), "e.pgm");
+ }
// Closing.
- image2d<float> clo = morpho::closing::volume(edges, world::inter_pixel::e2e(), atoi(argv[2]));
+ mln_VAR(clo, morpho::closing::volume(e, world::inter_pixel::e2e(), atoi(argv[2])));
+
+ {
+ // Display.
+ mln_VAR(display_clo, world::inter_pixel::display_edge(clo.unmorph_(), 0.0, 3));
+ io::pgm::save(level::stretch(int_u8(), display_clo), "edges2.pgm");
+ }
+
+ typedef label_16 L;
+ L nbasins;
+ mln_VAR(wst, morpho::watershed::flooding(clo, world::inter_pixel::e2e(), nbasins));
+
+ mln_VAR(w, wst.unmorph_());
+ data::fill((w | (!world::inter_pixel::is_separator())).rw(), nbasins.next());
+ io::ppm::save(debug::colorize(value::rgb8(), w, nbasins.next()), "result.ppm");
+
+
+
+
+
+
+
+
+
+
+
+
+ /*mln_VAR(clo, morpho::closing::volume(edges | world::inter_pixel::dim2::is_edge(), world::inter_pixel::e2e(), atoi(argv[2])));
+
+ // Debug.
+ //debug::println("clo", clo);
+
+ // Display.
+ image2d<float> display_ima2 = world::inter_pixel::display_edge(clo.unmorph_(), 0.0, 3);
+ io::pgm::save(level::stretch(int_u8(), display_ima2), "edges2.pgm");
// Watershed.
- label_16 nbasins;
- image2d<label_16> wst = morpho::watershed::flooding(clo, world::inter_pixel::e2e(), nbasins);
+ typedef label_16 L;
+ L nbasins;
+ mln_VAR(wst, morpho::watershed::flooding(clo, world::inter_pixel::e2e(), nbasins));
+
+ // Debug.
+ //debug::println("wst", wst);
+
+ // Extension.
+ image2d<L> w_all = wst.unmorph_();
+ // edges -> pixel
+ mln_VAR(w_pixels, w_all | world::inter_pixel::dim2::is_pixel());
+ data::paste(morpho::dilation(extend(w_pixels, pw::value(w_all)), c4().win()), w_all);
+ // edges -> dots
+ mln_VAR(w_dots, w_all | world::inter_pixel::dim2::is_dot());
+ data::paste(morpho::erosion(extend(w_dots, pw::value(w_all)), c4().win()), w_all);
+
// Save labels map.
std::cout << "nbasins: " << nbasins << std::endl;
- io::dump::save(wst, "watershed_fixed.dump");
+ io::dump::save(wst.unmorph_(), "watershed_fixed.dump");*/
return 0;
}
Index: trunk/milena/sandbox/fabien/igr/Makefile.rules
===================================================================
--- trunk/milena/sandbox/fabien/igr/Makefile.rules (revision 3772)
+++ trunk/milena/sandbox/fabien/igr/Makefile.rules (revision 3773)
@@ -1,5 +1,5 @@
CXX = g++
-CXXFLAGS = -Wall -Wextra -DNDEBUG -O3
+CXXFLAGS = -Wall -Wextra -DNDEBUG -O1
DICOM_INC = -I/usr/local/include/gdcm-2.0
DICOM_LIBS = -lgdcmCommon -lgdcmDICT -lgdcmDSED -lgdcmIOD -lgdcmMSFF -lgdcmexpat -lgdcmjpeg12 -lgdcmjpeg16 -lgdcmjpeg8 -lgdcmopenjpeg -lgdcmuuid -lgdcmzlib \
Index: trunk/milena/sandbox/fabien/TODO
===================================================================
--- trunk/milena/sandbox/fabien/TODO (revision 3772)
+++ trunk/milena/sandbox/fabien/TODO (revision 3773)
@@ -7,5 +7,8 @@
||----w |
|| ||
-[ ] Create values between pixels
-[ ] Watershed between pixels
+[X] Create values between pixels
+[X] Watershed between pixels
+[ ] Sum of watershed slices
+[X] Fix display_edge
+[ ] Save edges image
1
0
* fabien/igr/Makefile.rules: Optimization flag is now -O1.
* fabien/igr/seg_fixed.cc: Fixed 'float' bug on edges.
---
milena/sandbox/ChangeLog | 6 +
milena/sandbox/fabien/TODO | 7 +-
milena/sandbox/fabien/igr/Makefile.rules | 2 +-
milena/sandbox/fabien/igr/seg_fixed.cc | 175 ++++++++++++++++++++++++++++--
4 files changed, 175 insertions(+), 15 deletions(-)
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index 0e9423a..d86c05e 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -1,3 +1,9 @@
+2009-05-07 Fabien Freling <fabien.freling(a)lrde.epita.fr>
+
+ Fixed watershed, now works on edges.
+ * fabien/igr/Makefile.rules: Optimization flag is now -O1.
+ * fabien/igr/seg_fixed.cc: Fixed 'float' bug on edges.
+
2009-05-06 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
New ESIEE stuff.
diff --git a/milena/sandbox/fabien/TODO b/milena/sandbox/fabien/TODO
index 9f2b39e..daebf19 100644
--- a/milena/sandbox/fabien/TODO
+++ b/milena/sandbox/fabien/TODO
@@ -7,5 +7,8 @@
||----w |
|| ||
-[ ] Create values between pixels
-[ ] Watershed between pixels
+[X] Create values between pixels
+[X] Watershed between pixels
+[ ] Sum of watershed slices
+[X] Fix display_edge
+[ ] Save edges image
diff --git a/milena/sandbox/fabien/igr/Makefile.rules b/milena/sandbox/fabien/igr/Makefile.rules
index b78781f..0ef4330 100644
--- a/milena/sandbox/fabien/igr/Makefile.rules
+++ b/milena/sandbox/fabien/igr/Makefile.rules
@@ -1,5 +1,5 @@
CXX = g++
-CXXFLAGS = -Wall -Wextra -DNDEBUG -O3
+CXXFLAGS = -Wall -Wextra -DNDEBUG -O1
DICOM_INC = -I/usr/local/include/gdcm-2.0
DICOM_LIBS = -lgdcmCommon -lgdcmDICT -lgdcmDSED -lgdcmIOD -lgdcmMSFF -lgdcmexpat -lgdcmjpeg12 -lgdcmjpeg16 -lgdcmjpeg8 -lgdcmopenjpeg -lgdcmuuid -lgdcmzlib \
diff --git a/milena/sandbox/fabien/igr/seg_fixed.cc b/milena/sandbox/fabien/igr/seg_fixed.cc
index 08c6133..d0b759f 100644
--- a/milena/sandbox/fabien/igr/seg_fixed.cc
+++ b/milena/sandbox/fabien/igr/seg_fixed.cc
@@ -5,34 +5,53 @@
#include <mln/core/alias/neighb2d.hh>
#include <mln/core/image/image3d.hh>
#include <mln/core/image/slice_image.hh>
+#include <mln/core/image/image_if.hh>
#include <mln/core/routine/duplicate.hh>
+#include <mln/core/routine/extend.hh>
+#include <mln/core/var.hh>
#include <mln/io/dump/all.hh>
#include <mln/io/pgm/save.hh>
+#include <mln/io/ppm/save.hh>
#include <mln/value/int_u8.hh>
#include <mln/value/int_u12.hh>
#include <mln/value/label_16.hh>
+#include <mln/value/rgb8.hh>
+#include <mln/value/float01_8.hh>
#include <mln/accu/sum.hh>
#include <mln/data/fill.hh>
+#include <mln/data/paste.hh>
#include <mln/debug/quiet.hh>
#include <mln/convert/from_to.hh>
#include <mln/level/compute.hh>
#include <mln/level/stretch.hh>
+#include <mln/make/image2d.hh>
+#include <mln/math/diff_abs.hh>
+#include <mln/morpho/dilation.hh>
+#include <mln/morpho/erosion.hh>
#include <mln/morpho/closing/volume.hh>
+#include <mln/morpho/elementary/gradient.hh>
#include <mln/morpho/watershed/flooding.hh>
+#include <mln/pw/all.hh>
#include <mln/util/array.hh>
#include <mln/world/inter_pixel/display_edge.hh>
+#include <mln/world/inter_pixel/compute.hh>
+#include <mln/world/inter_pixel/immerse.hh>
#include <mln/world/inter_pixel/neighb2d.hh>
-#include <mln/world/inter_pixel/dim2/is_edge.hh>
+#include <mln/world/inter_pixel/is_pixel.hh>
+
+#include <mln/debug/colorize.hh>
+#include <mln/debug/println.hh>
using namespace mln;
using value::int_u8;
using value::int_u12;
using value::label_16;
+using value::float01_8;
@@ -77,7 +96,7 @@ compute_dist(image2d<util::array<I> >& ima_arr,
else
res = 0.f;
- //std::cout << "dist: " << res << std::endl;
+ res = res;
return 1 - res;
}
@@ -132,6 +151,67 @@ dist_on_edges(image2d<util::array<I> >& ima_arr)
}
+// Dummy.
+///////////////////////////////////////////////////////////////////////////////
+template <typename I, typename N>
+inline
+image2d<int>
+dummy_dist_on_edges(const I& input, const N& nbh)
+{
+ image2d<int> output;
+ initialize(output, input);
+ data::fill(output, 0);
+
+ mln_piter(I) p(input.domain());
+ mln_niter(N) n(nbh, p);
+ for_all(p)
+ {
+ n.start();
+ int c1 = input(n);
+ n.next();
+ int c2 = input(n);
+ output(p) = math::diff_abs(c1, c2);
+ }
+
+ return output;
+}
+
+
+
+// Distance function.
+//-------------------
+
+struct dist_t : Function_vv2v<dist_t>
+{
+ typedef float result;
+
+ template <typename V>
+ float operator()(util::array<V> v1, util::array<V> v2) const
+ {
+ float res = 0.f;
+
+ for (unsigned i = 0; i < v1.nelements(); ++i)
+ res += std::min(v1[i], v2[i]);
+
+ image1d<V> tmp_ima;
+ accu::sum<V> accu_sum;
+
+ convert::from_to(v1, tmp_ima);
+ float sum_v1 = level::compute(accu_sum, tmp_ima);
+
+ convert::from_to(v2, tmp_ima);
+ float sum_v2 = level::compute(accu_sum, tmp_ima);
+
+ res /= std::max(sum_v1, sum_v2);
+
+ return 1 - res;
+ }
+} dist;
+
+
+
+
+
@@ -146,10 +226,12 @@ int main(int argc, char* argv[])
if (argc != 3)
return usage(argv[0]);
+
// Initialization.
image3d<int_u12> input;
io::dump::load(input, argv[1]);
- image2d<util::array<int_u12> > ima_arr;
+ typedef image2d<util::array<int_u12> > I;
+ I ima_arr;
initialize(ima_arr, slice(input, 0));
for (unsigned int i = 0; i < input.nslices(); ++i)
{
@@ -159,23 +241,92 @@ int main(int argc, char* argv[])
ima_arr(p).append(tmp_slice(p));
}
- // Edges computation.
- image2d<float> edges = dist_on_edges(ima_arr);
- // Display.
- image2d<float> display_ima = world::inter_pixel::display_edge(edges, 0.0, 3);
- io::pgm::save(level::stretch(int_u8(), display_ima), "edges.pgm");
+ // Edges image creation.
+ //image2d<float> edges = dist_on_edges(ima_arr);
+ typedef image_if<I, world::inter_pixel::is_pixel> Ix;
+ Ix imax = world::inter_pixel::immerse(ima_arr);
+
+ // Edges distance computation.
+ mln_VAR(edges, world::inter_pixel::compute(imax, dist));
+
+ {
+ // Display.
+ mln_VAR(display_ima, world::inter_pixel::display_edge(edges.unmorph_(), 0.0, 3));
+ io::pgm::save(level::stretch(int_u8(), display_ima), "edges.pgm");
+ }
+
+ // Save edges.
+ //mln_VAR(e, edges.unmorph_());
+ //data::fill((e | (!world::inter_pixel::is_separator())).rw(), nbasins.next());
+ //io::pgm::save(level::stretch(int_u8(), edges.unmorph_()), "edges_raw.pgm");
+
+ mln_VAR(e, level::stretch(int_u8(), edges));
+
+ {
+ // Display.
+ mln_VAR(display_ima, world::inter_pixel::display_edge(e.unmorph_(), 0.0, 3));
+ io::pgm::save(level::stretch(int_u8(), display_ima), "e.pgm");
+ }
// Closing.
- image2d<float> clo = morpho::closing::volume(edges, world::inter_pixel::e2e(), atoi(argv[2]));
+ mln_VAR(clo, morpho::closing::volume(e, world::inter_pixel::e2e(), atoi(argv[2])));
+
+ {
+ // Display.
+ mln_VAR(display_clo, world::inter_pixel::display_edge(clo.unmorph_(), 0.0, 3));
+ io::pgm::save(level::stretch(int_u8(), display_clo), "edges2.pgm");
+ }
+
+ typedef label_16 L;
+ L nbasins;
+ mln_VAR(wst, morpho::watershed::flooding(clo, world::inter_pixel::e2e(), nbasins));
+
+ mln_VAR(w, wst.unmorph_());
+ data::fill((w | (!world::inter_pixel::is_separator())).rw(), nbasins.next());
+ io::ppm::save(debug::colorize(value::rgb8(), w, nbasins.next()), "result.ppm");
+
+
+
+
+
+
+
+
+
+
+
+
+ /*mln_VAR(clo, morpho::closing::volume(edges | world::inter_pixel::dim2::is_edge(), world::inter_pixel::e2e(), atoi(argv[2])));
+
+ // Debug.
+ //debug::println("clo", clo);
+
+ // Display.
+ image2d<float> display_ima2 = world::inter_pixel::display_edge(clo.unmorph_(), 0.0, 3);
+ io::pgm::save(level::stretch(int_u8(), display_ima2), "edges2.pgm");
// Watershed.
- label_16 nbasins;
- image2d<label_16> wst = morpho::watershed::flooding(clo, world::inter_pixel::e2e(), nbasins);
+ typedef label_16 L;
+ L nbasins;
+ mln_VAR(wst, morpho::watershed::flooding(clo, world::inter_pixel::e2e(), nbasins));
+
+ // Debug.
+ //debug::println("wst", wst);
+
+ // Extension.
+ image2d<L> w_all = wst.unmorph_();
+ // edges -> pixel
+ mln_VAR(w_pixels, w_all | world::inter_pixel::dim2::is_pixel());
+ data::paste(morpho::dilation(extend(w_pixels, pw::value(w_all)), c4().win()), w_all);
+ // edges -> dots
+ mln_VAR(w_dots, w_all | world::inter_pixel::dim2::is_dot());
+ data::paste(morpho::erosion(extend(w_dots, pw::value(w_all)), c4().win()), w_all);
+
// Save labels map.
std::cout << "nbasins: " << nbasins << std::endl;
- io::dump::save(wst, "watershed_fixed.dump");
+ io::dump::save(wst.unmorph_(), "watershed_fixed.dump");*/
return 0;
}
--
1.6.1.2
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Fix fun stat mahalanobis.
* mln/fun/stat/mahalanobis.hh (var_1, mean): Rename as...
(var_1_, mean_): ...these.
Protect them.
(mean_t, mean): New typedef and method.
(operator()): Fix missing sqrt.
* tests/fun/stat/mahalanobis.cc: Augment.
mln/fun/stat/mahalanobis.hh | 24 +++++++++++++++++++-----
tests/fun/stat/mahalanobis.cc | 17 ++++++++---------
2 files changed, 27 insertions(+), 14 deletions(-)
Index: mln/fun/stat/mahalanobis.hh
--- mln/fun/stat/mahalanobis.hh (revision 3771)
+++ mln/fun/stat/mahalanobis.hh (working copy)
@@ -32,6 +32,7 @@
///
/// Define the FIXME
+# include <cmath>
# include <mln/core/concept/function.hh>
# include <mln/algebra/vec.hh>
# include <mln/algebra/mat.hh>
@@ -59,8 +60,13 @@
float operator()(const V& v) const;
- algebra::mat<n,n,float> var_1;
- algebra::vec<n,float> mean;
+ typedef algebra::vec<n,float> mean_t;
+
+ mean_t mean() const;
+
+ protected:
+ algebra::mat<n,n,float> var_1_;
+ algebra::vec<n,float> mean_;
};
@@ -71,8 +77,8 @@
mahalanobis<V>::mahalanobis(const algebra::mat<V::dim,V::dim,float>& var,
const algebra::vec<V::dim,float>& mean)
{
- var_1 = var._1();
- mean = mean;
+ var_1_ = var._1();
+ mean_ = mean;
}
template <typename V>
@@ -80,7 +86,15 @@
float
mahalanobis<V>::operator()(const V& v) const
{
- return (v - mean).t() * var_1 * (v - mean);
+ return std::sqrt((v - mean_).t() * var_1_ * (v - mean_));
+ }
+
+ template <typename V>
+ inline
+ typename mahalanobis<V>::mean_t
+ mahalanobis<V>::mean() const
+ {
+ return mean_;
}
# endif // ! MLN_INCLUDE_ONLY
Index: tests/fun/stat/mahalanobis.cc
--- tests/fun/stat/mahalanobis.cc (revision 3771)
+++ tests/fun/stat/mahalanobis.cc (working copy)
@@ -60,15 +60,14 @@
for (int i = 0; i < n; ++i)
a.take(v[i]);
-// vec3f m = a.mean();
-// mln_assertion(m[0] > 0.4 && m[0] < 0.6);
-// mln_assertion(m[1] > 0.9 && m[1] < 1.1);
-// mln_assertion(m[2] > 1.4 && m[2] < 1.6);
-
fun::stat::mahalanobis<vec3f> f(a.variance(), a.mean());
+ mln_assertion(f(a.mean()) == 0.f);
-// algebra::mat<3,3,float> s_1 = a.variance()._1();
-// mln_assertion(s_1(0,0) > 11 && s_1(0,0) < 13);
-// mln_assertion(s_1(1,1) > 2 && s_1(1,1) < 4);
-// mln_assertion(s_1(2,2) > 1.1 && s_1(2,2) < 1.5);
+ float sum = 0.f;
+ for (int i = 0; i < n; ++i)
+ {
+ float f_ = f(v[i]);
+ sum += f_ * f_;
+ }
+ mln_assertion(std::abs(sum / n - 3.f) < 0.00002f);
}
1
0
* mln/fun/stat/mahalanobis.hh (var_1, mean): Rename as...
(var_1_, mean_): ...these.
Protect them.
(mean_t, mean): New typedef and method.
(operator()): Fix missing sqrt.
* tests/fun/stat/mahalanobis.cc: Augment.
---
milena/ChangeLog | 11 +++++++++++
milena/mln/fun/stat/mahalanobis.hh | 24 +++++++++++++++++++-----
milena/tests/fun/stat/mahalanobis.cc | 17 ++++++++---------
3 files changed, 38 insertions(+), 14 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 9ac5049..702a0dc 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,16 @@
2009-05-07 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
+ Fix fun stat mahalanobis.
+
+ * mln/fun/stat/mahalanobis.hh (var_1, mean): Rename as...
+ (var_1_, mean_): ...these.
+ Protect them.
+ (mean_t, mean): New typedef and method.
+ (operator()): Fix missing sqrt.
+ * tests/fun/stat/mahalanobis.cc: Augment.
+
+2009-05-07 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
+
Fix missing files and tests in world inter-pixel.
* mln/world/inter_pixel/all.hh: New.
diff --git a/milena/mln/fun/stat/mahalanobis.hh b/milena/mln/fun/stat/mahalanobis.hh
index 79eea0e..967ad29 100644
--- a/milena/mln/fun/stat/mahalanobis.hh
+++ b/milena/mln/fun/stat/mahalanobis.hh
@@ -32,6 +32,7 @@
///
/// Define the FIXME
+# include <cmath>
# include <mln/core/concept/function.hh>
# include <mln/algebra/vec.hh>
# include <mln/algebra/mat.hh>
@@ -59,8 +60,13 @@ namespace mln
float operator()(const V& v) const;
- algebra::mat<n,n,float> var_1;
- algebra::vec<n,float> mean;
+ typedef algebra::vec<n,float> mean_t;
+
+ mean_t mean() const;
+
+ protected:
+ algebra::mat<n,n,float> var_1_;
+ algebra::vec<n,float> mean_;
};
@@ -71,8 +77,8 @@ namespace mln
mahalanobis<V>::mahalanobis(const algebra::mat<V::dim,V::dim,float>& var,
const algebra::vec<V::dim,float>& mean)
{
- var_1 = var._1();
- mean = mean;
+ var_1_ = var._1();
+ mean_ = mean;
}
template <typename V>
@@ -80,7 +86,15 @@ namespace mln
float
mahalanobis<V>::operator()(const V& v) const
{
- return (v - mean).t() * var_1 * (v - mean);
+ return std::sqrt((v - mean_).t() * var_1_ * (v - mean_));
+ }
+
+ template <typename V>
+ inline
+ typename mahalanobis<V>::mean_t
+ mahalanobis<V>::mean() const
+ {
+ return mean_;
}
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/tests/fun/stat/mahalanobis.cc b/milena/tests/fun/stat/mahalanobis.cc
index 7df7af2..a2f1e00 100644
--- a/milena/tests/fun/stat/mahalanobis.cc
+++ b/milena/tests/fun/stat/mahalanobis.cc
@@ -60,15 +60,14 @@ int main()
for (int i = 0; i < n; ++i)
a.take(v[i]);
-// vec3f m = a.mean();
-// mln_assertion(m[0] > 0.4 && m[0] < 0.6);
-// mln_assertion(m[1] > 0.9 && m[1] < 1.1);
-// mln_assertion(m[2] > 1.4 && m[2] < 1.6);
-
fun::stat::mahalanobis<vec3f> f(a.variance(), a.mean());
+ mln_assertion(f(a.mean()) == 0.f);
-// algebra::mat<3,3,float> s_1 = a.variance()._1();
-// mln_assertion(s_1(0,0) > 11 && s_1(0,0) < 13);
-// mln_assertion(s_1(1,1) > 2 && s_1(1,1) < 4);
-// mln_assertion(s_1(2,2) > 1.1 && s_1(2,2) < 1.5);
+ float sum = 0.f;
+ for (int i = 0; i < n; ++i)
+ {
+ float f_ = f(v[i]);
+ sum += f_ * f_;
+ }
+ mln_assertion(std::abs(sum / n - 3.f) < 0.00002f);
}
--
1.6.1.2
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Fix missing files and tests in world inter-pixel.
* mln/world/inter_pixel/all.hh: New.
* mln/world/inter_pixel/dim2/all.hh: Fix copyright.
* mln/world/all.hh: New.
* mln/all.hh: Update.
* tests/world/inter_pixel/is_separator.cc: New.
* tests/world/inter_pixel/is_pixel.cc: New.
* tests/world/inter_pixel/Makefile.am: Update.
* tests/world/inter_pixel/separator_to_pixels.cc: New.
* mln/world/inter_pixel/make: Remove; useless.
* tests/world/inter_pixel/image2full.cc: Remove;
new stuff is...
* tests/world/inter_pixel/immerse.hh: ...this.
mln/all.hh | 1
mln/world/all.hh | 41 ++++++++++++++++++
mln/world/inter_pixel/all.hh | 47 ++++++++++++++++++++
mln/world/inter_pixel/dim2/all.hh | 6 +-
tests/world/inter_pixel/Makefile.am | 12 ++++-
tests/world/inter_pixel/is_pixel.cc | 46 ++++++++++++++++++++
tests/world/inter_pixel/is_separator.cc | 47 ++++++++++++++++++++
tests/world/inter_pixel/separator_to_pixels.cc | 56 +++++++++++++++++++++++++
8 files changed, 250 insertions(+), 6 deletions(-)
Index: mln/world/inter_pixel/all.hh
--- mln/world/inter_pixel/all.hh (revision 0)
+++ mln/world/inter_pixel/all.hh (revision 0)
@@ -0,0 +1,47 @@
+// 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.
+
+#ifndef MLN_WORLD_INTER_PIXEL_ALL_HH
+# define MLN_WORLD_INTER_PIXEL_ALL_HH
+
+/// \file mln/world/inter_pixel/all.hh
+///
+/// File that includes all the inter-pixel routines.
+
+
+// Sub-directories.
+# include <mln/world/inter_pixel/dim2/all.hh>
+
+
+# include <mln/world/inter_pixel/compute.hh>
+# include <mln/world/inter_pixel/immerse.hh>
+# include <mln/world/inter_pixel/is_separator.hh>
+# include <mln/world/inter_pixel/is_pixel.hh>
+# include <mln/world/inter_pixel/separator_to_pixels.hh>
+
+
+#endif // ! MLN_WORLD_INTER_PIXEL_ALL_HH
Index: mln/world/inter_pixel/dim2/all.hh
--- mln/world/inter_pixel/dim2/all.hh (revision 3770)
+++ mln/world/inter_pixel/dim2/all.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2008 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
@@ -30,10 +31,9 @@
/// \file mln/world/inter_pixel/dim2/all.hh
///
-/// File that includes all the dim2 routines.
+/// File that includes all the inter-pixel 2D routines.
-// Local directory.
# include <mln/world/inter_pixel/dim2/is_dot.hh>
# include <mln/world/inter_pixel/dim2/is_edge.hh>
# include <mln/world/inter_pixel/dim2/is_pixel.hh>
Index: mln/world/all.hh
--- mln/world/all.hh (revision 0)
+++ mln/world/all.hh (revision 0)
@@ -0,0 +1,41 @@
+// 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.
+
+#ifndef MLN_WORLD_ALL_HH
+# define MLN_WORLD_ALL_HH
+
+/// \file mln/world/all.hh
+///
+/// File that includes all the world routines.
+
+
+// Sub-directories.
+# include <mln/world/binary_2d/all.hh>
+# include <mln/world/inter_pixel/all.hh>
+
+
+#endif // ! MLN_WORLD_ALL_HH
Index: mln/all.hh
--- mln/all.hh (revision 3770)
+++ mln/all.hh (working copy)
@@ -72,6 +72,7 @@
#include <mln/util/all.hh>
#include <mln/value/all.hh>
#include <mln/win/all.hh>
+#include <mln/world/all.hh>
#include <mln/essential/1d.hh>
#include <mln/essential/2d.hh>
Index: tests/world/inter_pixel/is_separator.cc
--- tests/world/inter_pixel/is_separator.cc (revision 0)
+++ tests/world/inter_pixel/is_separator.cc (revision 0)
@@ -0,0 +1,47 @@
+// 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/world/inter_pixel/is_separator.cc
+///
+/// Tests on mln::world::inter_pixel::is_separator.
+
+#include <mln/core/alias/point2d.hh>
+#include <mln/world/inter_pixel/is_separator.hh>
+
+
+int main()
+{
+ using namespace mln;
+ using namespace world::inter_pixel;
+
+ point2d p00(0, 0), p01(0, 1), p10(1, 0), p11(1, 1);
+
+ mln_assertion(! is_separator()(p00));
+ mln_assertion( is_separator()(p01));
+ mln_assertion(! is_separator()(p11));
+ mln_assertion( is_separator()(p10));
+}
Property changes on: tests/world/inter_pixel/is_separator.cc
___________________________________________________________________
Added: svn:mergeinfo
Index: tests/world/inter_pixel/is_pixel.cc
--- tests/world/inter_pixel/is_pixel.cc (revision 0)
+++ tests/world/inter_pixel/is_pixel.cc (revision 0)
@@ -0,0 +1,46 @@
+// 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/world/inter_pixel/is_pixel.cc
+///
+/// Tests on mln::world::inter_pixel::is_pixel.
+
+#include <mln/core/alias/point2d.hh>
+#include <mln/world/inter_pixel/is_pixel.hh>
+
+
+int main()
+{
+ using namespace mln;
+ using namespace world::inter_pixel;
+
+ point2d p00(0, 0), p01(0, 1), p11(1, 1);
+
+ mln_assertion( is_pixel()(p00));
+ mln_assertion(! is_pixel()(p01));
+ mln_assertion(! is_pixel()(p11));
+}
Index: tests/world/inter_pixel/Makefile.am
--- tests/world/inter_pixel/Makefile.am (revision 3770)
+++ tests/world/inter_pixel/Makefile.am (working copy)
@@ -6,10 +6,16 @@
dim2
check_PROGRAMS = \
- image2full \
- immerse
+ compute \
+ immerse \
+ is_pixel \
+ is_separator \
+ separator_to_pixels
-image2full_SOURCES = image2full.cc
+compute_SOURCES = compute.cc
immerse_SOURCES = immerse.cc
+is_pixel_SOURCES = is_pixel.cc
+is_separator_SOURCES = is_separator.cc
+separator_to_pixels_SOURCES = separator_to_pixels.cc
TESTS = $(check_PROGRAMS)
Index: tests/world/inter_pixel/separator_to_pixels.cc
--- tests/world/inter_pixel/separator_to_pixels.cc (revision 0)
+++ tests/world/inter_pixel/separator_to_pixels.cc (revision 0)
@@ -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/world/inter_pixel/separator_to_pixels.cc
+///
+/// Tests on mln::world::inter_pixel::separator_to_pixels.
+
+#include <mln/core/alias/point2d.hh>
+#include <mln/world/inter_pixel/separator_to_pixels.hh>
+
+
+int main()
+{
+ using namespace mln;
+ using namespace world::inter_pixel;
+
+ point2d
+ p00(0, 0), p01(0, 1), p02(0, 2),
+ p10(1, 0),
+ p20(2, 0);
+
+ {
+ point2d p00_, p02_;
+ separator_to_pixels(p01, p00_, p02_);
+ mln_assertion(p00_ == p00 && p02_ == p02);
+ }
+ {
+ point2d p00_, p20_;
+ separator_to_pixels(p10, p00_, p20_);
+ mln_assertion(p00_ == p00 && p20_ == p20);
+ }
+}
1
0
07 May '09
* mln/world/inter_pixel/all.hh: New.
* mln/world/inter_pixel/dim2/all.hh: Fix copyright.
* mln/world/all.hh: New.
* mln/all.hh: Update.
* tests/world/inter_pixel/is_separator.cc: New.
* tests/world/inter_pixel/is_pixel.cc: New.
* tests/world/inter_pixel/Makefile.am: Update.
* tests/world/inter_pixel/separator_to_pixels.cc: New.
* mln/world/inter_pixel/make: Remove; useless.
* tests/world/inter_pixel/image2full.cc: Remove;
new stuff is...
* tests/world/inter_pixel/immerse.hh: ...this.
---
milena/ChangeLog | 17 +++++++
milena/mln/all.hh | 1 +
milena/mln/world/{inter_pixel/dim2 => }/all.hh | 20 ++++-----
milena/mln/world/inter_pixel/{dim2 => }/all.hh | 26 ++++++-----
milena/mln/world/inter_pixel/dim2/all.hh | 6 +-
milena/tests/world/inter_pixel/Makefile.am | 12 ++++-
.../inter_pixel/{image2full.cc => is_pixel.cc} | 34 ++++----------
.../world/inter_pixel/is_separator.cc} | 28 +++++++-----
.../{image2full.cc => separator_to_pixels.cc} | 48 +++++++++-----------
9 files changed, 102 insertions(+), 90 deletions(-)
copy milena/mln/world/{inter_pixel/dim2 => }/all.hh (71%)
copy milena/mln/world/inter_pixel/{dim2 => }/all.hh (69%)
copy milena/tests/world/inter_pixel/{image2full.cc => is_pixel.cc} (66%)
copy milena/{mln/world/inter_pixel/dim2/all.hh => tests/world/inter_pixel/is_separator.cc} (70%)
rename milena/tests/world/inter_pixel/{image2full.cc => separator_to_pixels.cc} (66%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 10648a0..9ac5049 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,20 @@
+2009-05-07 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
+
+ Fix missing files and tests in world inter-pixel.
+
+ * mln/world/inter_pixel/all.hh: New.
+ * mln/world/inter_pixel/dim2/all.hh: Fix copyright.
+ * mln/world/all.hh: New.
+ * mln/all.hh: Update.
+ * tests/world/inter_pixel/is_separator.cc: New.
+ * tests/world/inter_pixel/is_pixel.cc: New.
+ * tests/world/inter_pixel/Makefile.am: Update.
+ * tests/world/inter_pixel/separator_to_pixels.cc: New.
+ * mln/world/inter_pixel/make: Remove; useless.
+ * tests/world/inter_pixel/image2full.cc: Remove;
+ new stuff is...
+ * tests/world/inter_pixel/immerse.hh: ...this.
+
2009-05-07 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
Move object_id.hh to mln/util and add a missing operator<
diff --git a/milena/mln/all.hh b/milena/mln/all.hh
index cc4374b..7f77db4 100644
--- a/milena/mln/all.hh
+++ b/milena/mln/all.hh
@@ -72,6 +72,7 @@
#include <mln/util/all.hh>
#include <mln/value/all.hh>
#include <mln/win/all.hh>
+#include <mln/world/all.hh>
#include <mln/essential/1d.hh>
#include <mln/essential/2d.hh>
diff --git a/milena/mln/world/inter_pixel/dim2/all.hh b/milena/mln/world/all.hh
similarity index 71%
copy from milena/mln/world/inter_pixel/dim2/all.hh
copy to milena/mln/world/all.hh
index 1c7131b..7154654 100644
--- a/milena/mln/world/inter_pixel/dim2/all.hh
+++ b/milena/mln/world/all.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// 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
@@ -25,19 +25,17 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_WORLD_INTER_PIXEL_DIM2_ALL_HH
-# define MLN_WORLD_INTER_PIXEL_DIM2_ALL_HH
+#ifndef MLN_WORLD_ALL_HH
+# define MLN_WORLD_ALL_HH
-/// \file mln/world/inter_pixel/dim2/all.hh
+/// \file mln/world/all.hh
///
-/// File that includes all the dim2 routines.
+/// File that includes all the world routines.
-// Local directory.
-# include <mln/world/inter_pixel/dim2/is_dot.hh>
-# include <mln/world/inter_pixel/dim2/is_edge.hh>
-# include <mln/world/inter_pixel/dim2/is_pixel.hh>
-# include <mln/world/inter_pixel/dim2/is_row_odd.hh>
+// Sub-directories.
+# include <mln/world/binary_2d/all.hh>
+# include <mln/world/inter_pixel/all.hh>
-#endif // ! MLN_WORLD_INTER_PIXEL_DIM2_ALL_HH
+#endif // ! MLN_WORLD_ALL_HH
diff --git a/milena/mln/world/inter_pixel/dim2/all.hh b/milena/mln/world/inter_pixel/all.hh
similarity index 69%
copy from milena/mln/world/inter_pixel/dim2/all.hh
copy to milena/mln/world/inter_pixel/all.hh
index 1c7131b..da3b105 100644
--- a/milena/mln/world/inter_pixel/dim2/all.hh
+++ b/milena/mln/world/inter_pixel/all.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// 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
@@ -25,19 +25,23 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_WORLD_INTER_PIXEL_DIM2_ALL_HH
-# define MLN_WORLD_INTER_PIXEL_DIM2_ALL_HH
+#ifndef MLN_WORLD_INTER_PIXEL_ALL_HH
+# define MLN_WORLD_INTER_PIXEL_ALL_HH
-/// \file mln/world/inter_pixel/dim2/all.hh
+/// \file mln/world/inter_pixel/all.hh
///
-/// File that includes all the dim2 routines.
+/// File that includes all the inter-pixel routines.
-// Local directory.
-# include <mln/world/inter_pixel/dim2/is_dot.hh>
-# include <mln/world/inter_pixel/dim2/is_edge.hh>
-# include <mln/world/inter_pixel/dim2/is_pixel.hh>
-# include <mln/world/inter_pixel/dim2/is_row_odd.hh>
+// Sub-directories.
+# include <mln/world/inter_pixel/dim2/all.hh>
-#endif // ! MLN_WORLD_INTER_PIXEL_DIM2_ALL_HH
+# include <mln/world/inter_pixel/compute.hh>
+# include <mln/world/inter_pixel/immerse.hh>
+# include <mln/world/inter_pixel/is_separator.hh>
+# include <mln/world/inter_pixel/is_pixel.hh>
+# include <mln/world/inter_pixel/separator_to_pixels.hh>
+
+
+#endif // ! MLN_WORLD_INTER_PIXEL_ALL_HH
diff --git a/milena/mln/world/inter_pixel/dim2/all.hh b/milena/mln/world/inter_pixel/dim2/all.hh
index 1c7131b..8696371 100644
--- a/milena/mln/world/inter_pixel/dim2/all.hh
+++ b/milena/mln/world/inter_pixel/dim2/all.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2008 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
@@ -30,10 +31,9 @@
/// \file mln/world/inter_pixel/dim2/all.hh
///
-/// File that includes all the dim2 routines.
+/// File that includes all the inter-pixel 2D routines.
-// Local directory.
# include <mln/world/inter_pixel/dim2/is_dot.hh>
# include <mln/world/inter_pixel/dim2/is_edge.hh>
# include <mln/world/inter_pixel/dim2/is_pixel.hh>
diff --git a/milena/tests/world/inter_pixel/Makefile.am b/milena/tests/world/inter_pixel/Makefile.am
index fdbcea2..89f7bf7 100644
--- a/milena/tests/world/inter_pixel/Makefile.am
+++ b/milena/tests/world/inter_pixel/Makefile.am
@@ -6,10 +6,16 @@ SUBDIRS = \
dim2
check_PROGRAMS = \
- image2full \
- immerse
+ compute \
+ immerse \
+ is_pixel \
+ is_separator \
+ separator_to_pixels
-image2full_SOURCES = image2full.cc
+compute_SOURCES = compute.cc
immerse_SOURCES = immerse.cc
+is_pixel_SOURCES = is_pixel.cc
+is_separator_SOURCES = is_separator.cc
+separator_to_pixels_SOURCES = separator_to_pixels.cc
TESTS = $(check_PROGRAMS)
diff --git a/milena/tests/world/inter_pixel/image2full.cc b/milena/tests/world/inter_pixel/is_pixel.cc
similarity index 66%
copy from milena/tests/world/inter_pixel/image2full.cc
copy to milena/tests/world/inter_pixel/is_pixel.cc
index 06398a1..b783e80 100644
--- a/milena/tests/world/inter_pixel/image2full.cc
+++ b/milena/tests/world/inter_pixel/is_pixel.cc
@@ -25,36 +25,22 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/// \file tests/world/inter_pixel/image2full.cc
+/// \file tests/world/inter_pixel/is_pixel.cc
///
-/// Tests on mln::world::inter_pixel::image2full
+/// Tests on mln::world::inter_pixel::is_pixel.
+
+#include <mln/core/alias/point2d.hh>
+#include <mln/world/inter_pixel/is_pixel.hh>
-#include <mln/core/image/image2d.hh>
-#include <mln/make/image.hh>
-#include <mln/value/int_u8.hh>
-#include <mln/level/compare.hh>
-#include <mln/world/inter_pixel/image2full.hh>
int main()
{
using namespace mln;
+ using namespace world::inter_pixel;
- value::int_u8 vals[][3] = { { 3, 4, 5 },
- { 1, 3, 6 },
- { 8, 7, 3 } } ;
-
- value::int_u8 refs[][5] = { { 3, 0, 4, 0, 5 },
- { 0, 0, 0, 0, 0 },
- { 1, 0, 3, 0, 6 },
- { 0, 0, 0, 0, 0 },
- { 8, 0, 7, 0, 3 } };
-
- typedef image2d<value::int_u8> ima_t;
- ima_t ima = make::image(vals);
- ima_t ref = make::image(refs);
-
- ima_t ima_l = world::inter_pixel::image2full(ima);
-
- mln_assertion(ima_l == ref);
+ point2d p00(0, 0), p01(0, 1), p11(1, 1);
+ mln_assertion( is_pixel()(p00));
+ mln_assertion(! is_pixel()(p01));
+ mln_assertion(! is_pixel()(p11));
}
diff --git a/milena/mln/world/inter_pixel/dim2/all.hh b/milena/tests/world/inter_pixel/is_separator.cc
similarity index 70%
copy from milena/mln/world/inter_pixel/dim2/all.hh
copy to milena/tests/world/inter_pixel/is_separator.cc
index 1c7131b..7234acb 100644
--- a/milena/mln/world/inter_pixel/dim2/all.hh
+++ b/milena/tests/world/inter_pixel/is_separator.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// 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
@@ -25,19 +25,23 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_WORLD_INTER_PIXEL_DIM2_ALL_HH
-# define MLN_WORLD_INTER_PIXEL_DIM2_ALL_HH
-
-/// \file mln/world/inter_pixel/dim2/all.hh
+/// \file tests/world/inter_pixel/is_separator.cc
///
-/// File that includes all the dim2 routines.
+/// Tests on mln::world::inter_pixel::is_separator.
+
+#include <mln/core/alias/point2d.hh>
+#include <mln/world/inter_pixel/is_separator.hh>
-// Local directory.
-# include <mln/world/inter_pixel/dim2/is_dot.hh>
-# include <mln/world/inter_pixel/dim2/is_edge.hh>
-# include <mln/world/inter_pixel/dim2/is_pixel.hh>
-# include <mln/world/inter_pixel/dim2/is_row_odd.hh>
+int main()
+{
+ using namespace mln;
+ using namespace world::inter_pixel;
+ point2d p00(0, 0), p01(0, 1), p10(1, 0), p11(1, 1);
-#endif // ! MLN_WORLD_INTER_PIXEL_DIM2_ALL_HH
+ mln_assertion(! is_separator()(p00));
+ mln_assertion( is_separator()(p01));
+ mln_assertion(! is_separator()(p11));
+ mln_assertion( is_separator()(p10));
+}
diff --git a/milena/tests/world/inter_pixel/image2full.cc b/milena/tests/world/inter_pixel/separator_to_pixels.cc
similarity index 66%
rename from milena/tests/world/inter_pixel/image2full.cc
rename to milena/tests/world/inter_pixel/separator_to_pixels.cc
index 06398a1..fd77491 100644
--- a/milena/tests/world/inter_pixel/image2full.cc
+++ b/milena/tests/world/inter_pixel/separator_to_pixels.cc
@@ -25,36 +25,32 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/// \file tests/world/inter_pixel/image2full.cc
+/// \file tests/world/inter_pixel/separator_to_pixels.cc
///
-/// Tests on mln::world::inter_pixel::image2full
+/// Tests on mln::world::inter_pixel::separator_to_pixels.
+
+#include <mln/core/alias/point2d.hh>
+#include <mln/world/inter_pixel/separator_to_pixels.hh>
-#include <mln/core/image/image2d.hh>
-#include <mln/make/image.hh>
-#include <mln/value/int_u8.hh>
-#include <mln/level/compare.hh>
-#include <mln/world/inter_pixel/image2full.hh>
int main()
{
using namespace mln;
-
- value::int_u8 vals[][3] = { { 3, 4, 5 },
- { 1, 3, 6 },
- { 8, 7, 3 } } ;
-
- value::int_u8 refs[][5] = { { 3, 0, 4, 0, 5 },
- { 0, 0, 0, 0, 0 },
- { 1, 0, 3, 0, 6 },
- { 0, 0, 0, 0, 0 },
- { 8, 0, 7, 0, 3 } };
-
- typedef image2d<value::int_u8> ima_t;
- ima_t ima = make::image(vals);
- ima_t ref = make::image(refs);
-
- ima_t ima_l = world::inter_pixel::image2full(ima);
-
- mln_assertion(ima_l == ref);
-
+ using namespace world::inter_pixel;
+
+ point2d
+ p00(0, 0), p01(0, 1), p02(0, 2),
+ p10(1, 0),
+ p20(2, 0);
+
+ {
+ point2d p00_, p02_;
+ separator_to_pixels(p01, p00_, p02_);
+ mln_assertion(p00_ == p00 && p02_ == p02);
+ }
+ {
+ point2d p00_, p20_;
+ separator_to_pixels(p10, p00_, p20_);
+ mln_assertion(p00_ == p00 && p20_ == p20);
+ }
}
--
1.6.1.2
1
0
07 May '09
* mln/core/concept/object_id.hh: move...
* mln/util/object_id.hh: ... here. Add a missing operator<.
* mln/util/graph_ids.hh: update include path.
---
milena/ChangeLog | 9 ++
milena/mln/core/concept/object_id.hh | 220 ----------------------------------
milena/mln/util/graph_ids.hh | 2 +-
milena/mln/util/object_id.hh | 213 ++++++++++++++++++++++++++++++++
4 files changed, 223 insertions(+), 221 deletions(-)
delete mode 100644 milena/mln/core/concept/object_id.hh
create mode 100644 milena/mln/util/object_id.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 4430b6c..10648a0 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,4 +1,13 @@
2009-05-07 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
+ Move object_id.hh to mln/util and add a missing operator<
+
+ * mln/core/concept/object_id.hh: move...
+ * mln/util/object_id.hh: ... here. Add a missing operator<.
+
+ * mln/util/graph_ids.hh: update include path.
+
+2009-05-07 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
Move debug::colorize to labeling::colorize.
diff --git a/milena/mln/core/concept/object_id.hh b/milena/mln/core/concept/object_id.hh
deleted file mode 100644
index e8102df..0000000
--- a/milena/mln/core/concept/object_id.hh
+++ /dev/null
@@ -1,220 +0,0 @@
-// 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.
-// reasons why the executable file might be covered by the GNU General
-// Public License.
-
-
-#ifndef MLN_CORE_CONCEPT_OBJECT_ID_HH
-# define MLN_CORE_CONCEPT_OBJECT_ID_HH
-
-/// \file mln/core/concept/object_id.hh
-///
-/// Base class of an object id.
-
-
-# include <mln/core/concept/object.hh>
-# include <mln/value/concept/integer.hh>
-# include <mln/metal/abort.hh>
-
-namespace mln
-{
-
-
- /// Object category.
- template <typename E>
- struct Object_Id;
-
- template <>
- struct Object_Id<void>
- {
- };
-
-
-
- /// Base class of an object id.
- /// \tparam Tag the tag type
- /// \tparam Equiv the equivalent value.
- template <typename Tag, typename V>
- class object_id : public value::Integer< object_id<Tag, V> >
- {
- public:
- /// The underlying type id.
- typedef V value_t;
- typedef unsigned equiv;
- typedef V enc;
-
- /// Constructors
- /// @{
- object_id();
-
- template <typename V2>
- object_id(const V2& id);
-
- template <typename Tag2, typename V2>
- object_id(const object_id<Tag2,V2>& other);
- /// @}
-
- template <typename V2>
- object_id<Tag,V>& operator=(const V2& e);
-
- const V& value() const;
- V& value();
-
- operator unsigned() const;
-
- bool is_valid() const;
- void invalidate();
-
- unsigned to_equiv() const;
-
- protected:
- V id_;
- };
-
-
- template <typename Tag, typename V>
- bool
- operator==(const object_id<Tag,V>& lhs, const object_id<Tag,V>& rhs);
-
- template <typename Tag, typename V, typename V2>
- bool
- operator==(const object_id<Tag,V>& lhs, const Value<V2>& rhs);
-
-
-# ifndef MLN_INCLUDE_ONLY
-
-
- template <typename Tag, typename V>
- inline
- object_id<Tag,V>::object_id()
- : id_(mln_max(V))
- {
- }
-
- template <typename Tag, typename V>
- template <typename V2>
- inline
- object_id<Tag,V>::object_id(const V2& id)
- : id_(id)
- {
- mlc_converts_to(V2,V)::check();
- }
-
- template <typename Tag, typename V>
- template <typename Tag2, typename V2>
- inline
- object_id<Tag,V>::object_id(const object_id<Tag2,V2>& id)
- {
- typedef object_id<Tag2,V2> id_t;
- mlc_abort(id_t)::check();
- }
-
- template <typename Tag, typename V>
- template <typename V2>
- inline
- object_id<Tag,V>&
- object_id<Tag,V>::operator=(const V2& v)
- {
- mlc_converts_to(V2,V)::check();
-
- id_ = v;
- return *this;
- }
-
- template <typename Tag, typename V>
- inline
- V&
- object_id<Tag,V>::value()
- {
- return id_;
- }
-
- template <typename Tag, typename V>
- inline
- const V&
- object_id<Tag,V>::value() const
- {
- return id_;
- }
-
- template <typename Tag, typename V>
- inline
- object_id<Tag,V>::operator unsigned() const
- {
- return id_;
- }
-
-
- template <typename Tag, typename V>
- inline
- bool
- object_id<Tag,V>::is_valid() const
- {
- return id_ != mln_max(V);
- }
-
- template <typename Tag, typename V>
- inline
- void
- object_id<Tag,V>::invalidate()
- {
- id_ = mln_max(V);
- }
-
- template <typename Tag, typename V>
- inline
- unsigned
- object_id<Tag,V>::to_equiv() const
- {
- return id_;
- }
-
-
-
-
- template <typename Tag, typename V>
- inline
- bool
- operator==(const object_id<Tag,V>& lhs, const object_id<Tag,V>& rhs)
- {
- return lhs.value() == rhs.value();
- }
-
- template <typename Tag, typename V, typename V2>
- inline
- bool
- operator==(const object_id<Tag,V>& lhs, const Value<V2>& rhs)
- {
- return lhs.value() == exact(rhs).to_equiv();
- }
-
-# endif // ! MLN_INCLUDE_ONLY
-
-
-} // end of namespace mln
-
-#endif // ! MLN_CORE_CONCEPT_OBJECT_ID_HH
-
diff --git a/milena/mln/util/graph_ids.hh b/milena/mln/util/graph_ids.hh
index df3e981..2f9eab5 100644
--- a/milena/mln/util/graph_ids.hh
+++ b/milena/mln/util/graph_ids.hh
@@ -33,7 +33,7 @@
///
/// Definition of graph element ids.
-# include <mln/core/concept/object_id.hh>
+# include <mln/util/object_id.hh>
namespace mln
diff --git a/milena/mln/util/object_id.hh b/milena/mln/util/object_id.hh
new file mode 100644
index 0000000..b3ea879
--- /dev/null
+++ b/milena/mln/util/object_id.hh
@@ -0,0 +1,213 @@
+// 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.
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+
+#ifndef MLN_UTIL_OBJECT_ID_HH
+# define MLN_UTIL_OBJECT_ID_HH
+
+/// \file mln/core/concept/object_id.hh
+///
+/// Base class of an object id.
+
+
+# include <mln/core/concept/object.hh>
+# include <mln/value/concept/integer.hh>
+# include <mln/metal/abort.hh>
+
+namespace mln
+{
+
+ namespace util
+ {
+
+ /// Base class of an object id.
+ /// \tparam Tag the tag type
+ /// \tparam Equiv the equivalent value.
+ template <typename Tag, typename V>
+ class object_id : public value::Integer< object_id<Tag, V> >
+ {
+ public:
+ /// The underlying type id.
+ typedef V value_t;
+ typedef unsigned equiv;
+ typedef V enc;
+
+ /// Constructors
+ /// @{
+ object_id();
+
+ template <typename V2>
+ object_id(const V2& id);
+
+ template <typename Tag2, typename V2>
+ object_id(const object_id<Tag2,V2>& other);
+ /// @}
+
+ template <typename V2>
+ object_id<Tag,V>& operator=(const V2& e);
+
+ const V& value() const;
+ V& value();
+
+ operator unsigned() const;
+
+ bool is_valid() const;
+ void invalidate();
+
+ unsigned to_equiv() const;
+
+ protected:
+ V id_;
+ };
+
+
+ template <typename Tag, typename V>
+ bool
+ operator==(const object_id<Tag,V>& lhs, const object_id<Tag,V>& rhs);
+
+ template <typename Tag, typename V, typename V2>
+ bool
+ operator<(const object_id<Tag,V>& lhs, const object_id<Tag,V>& rhs);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename Tag, typename V>
+ inline
+ object_id<Tag,V>::object_id()
+ : id_(mln_max(V))
+ {
+ }
+
+ template <typename Tag, typename V>
+ template <typename V2>
+ inline
+ object_id<Tag,V>::object_id(const V2& id)
+ : id_(id)
+ {
+ mlc_converts_to(V2,V)::check();
+ }
+
+ template <typename Tag, typename V>
+ template <typename Tag2, typename V2>
+ inline
+ object_id<Tag,V>::object_id(const object_id<Tag2,V2>& id)
+ {
+ typedef object_id<Tag2,V2> id_t;
+ mlc_abort(id_t)::check();
+ }
+
+ template <typename Tag, typename V>
+ template <typename V2>
+ inline
+ object_id<Tag,V>&
+ object_id<Tag,V>::operator=(const V2& v)
+ {
+ mlc_converts_to(V2,V)::check();
+
+ id_ = v;
+ return *this;
+ }
+
+ template <typename Tag, typename V>
+ inline
+ V&
+ object_id<Tag,V>::value()
+ {
+ return id_;
+ }
+
+ template <typename Tag, typename V>
+ inline
+ const V&
+ object_id<Tag,V>::value() const
+ {
+ return id_;
+ }
+
+ template <typename Tag, typename V>
+ inline
+ object_id<Tag,V>::operator unsigned() const
+ {
+ return id_;
+ }
+
+
+ template <typename Tag, typename V>
+ inline
+ bool
+ object_id<Tag,V>::is_valid() const
+ {
+ return id_ != mln_max(V);
+ }
+
+ template <typename Tag, typename V>
+ inline
+ void
+ object_id<Tag,V>::invalidate()
+ {
+ id_ = mln_max(V);
+ }
+
+ template <typename Tag, typename V>
+ inline
+ unsigned
+ object_id<Tag,V>::to_equiv() const
+ {
+ return id_;
+ }
+
+
+
+
+ template <typename Tag, typename V>
+ inline
+ bool
+ operator==(const object_id<Tag,V>& lhs, const object_id<Tag,V>& rhs)
+ {
+ return lhs.value() == rhs.value();
+ }
+
+ template <typename Tag, typename V>
+ inline
+ bool
+ operator<(const object_id<Tag,V>& lhs, const object_id<Tag,V>& rhs)
+ {
+ return lhs.value() < rhs.value();
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::util
+
+} // end of namespace mln
+
+#endif // ! MLN_UTIL_OBJECT_ID_HH
+
--
1.5.6.5
1
0
[PATCH 09/31] Move object_id.hh to mln/util and add a missing operator<
by Roland Levillain 07 May '09
by Roland Levillain 07 May '09
07 May '09
* mln/core/concept/object_id.hh: move...
* mln/util/object_id.hh: ... here. Add a missing operator<.
* mln/util/graph_ids.hh: update include path.
---
milena/ChangeLog | 9 ++
milena/mln/core/concept/object_id.hh | 220 ----------------------------------
milena/mln/util/graph_ids.hh | 2 +-
milena/mln/util/object_id.hh | 213 ++++++++++++++++++++++++++++++++
4 files changed, 223 insertions(+), 221 deletions(-)
delete mode 100644 milena/mln/core/concept/object_id.hh
create mode 100644 milena/mln/util/object_id.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 4430b6c..10648a0 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,4 +1,13 @@
2009-05-07 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
+ Move object_id.hh to mln/util and add a missing operator<
+
+ * mln/core/concept/object_id.hh: move...
+ * mln/util/object_id.hh: ... here. Add a missing operator<.
+
+ * mln/util/graph_ids.hh: update include path.
+
+2009-05-07 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
Move debug::colorize to labeling::colorize.
diff --git a/milena/mln/core/concept/object_id.hh b/milena/mln/core/concept/object_id.hh
deleted file mode 100644
index e8102df..0000000
--- a/milena/mln/core/concept/object_id.hh
+++ /dev/null
@@ -1,220 +0,0 @@
-// 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.
-// reasons why the executable file might be covered by the GNU General
-// Public License.
-
-
-#ifndef MLN_CORE_CONCEPT_OBJECT_ID_HH
-# define MLN_CORE_CONCEPT_OBJECT_ID_HH
-
-/// \file mln/core/concept/object_id.hh
-///
-/// Base class of an object id.
-
-
-# include <mln/core/concept/object.hh>
-# include <mln/value/concept/integer.hh>
-# include <mln/metal/abort.hh>
-
-namespace mln
-{
-
-
- /// Object category.
- template <typename E>
- struct Object_Id;
-
- template <>
- struct Object_Id<void>
- {
- };
-
-
-
- /// Base class of an object id.
- /// \tparam Tag the tag type
- /// \tparam Equiv the equivalent value.
- template <typename Tag, typename V>
- class object_id : public value::Integer< object_id<Tag, V> >
- {
- public:
- /// The underlying type id.
- typedef V value_t;
- typedef unsigned equiv;
- typedef V enc;
-
- /// Constructors
- /// @{
- object_id();
-
- template <typename V2>
- object_id(const V2& id);
-
- template <typename Tag2, typename V2>
- object_id(const object_id<Tag2,V2>& other);
- /// @}
-
- template <typename V2>
- object_id<Tag,V>& operator=(const V2& e);
-
- const V& value() const;
- V& value();
-
- operator unsigned() const;
-
- bool is_valid() const;
- void invalidate();
-
- unsigned to_equiv() const;
-
- protected:
- V id_;
- };
-
-
- template <typename Tag, typename V>
- bool
- operator==(const object_id<Tag,V>& lhs, const object_id<Tag,V>& rhs);
-
- template <typename Tag, typename V, typename V2>
- bool
- operator==(const object_id<Tag,V>& lhs, const Value<V2>& rhs);
-
-
-# ifndef MLN_INCLUDE_ONLY
-
-
- template <typename Tag, typename V>
- inline
- object_id<Tag,V>::object_id()
- : id_(mln_max(V))
- {
- }
-
- template <typename Tag, typename V>
- template <typename V2>
- inline
- object_id<Tag,V>::object_id(const V2& id)
- : id_(id)
- {
- mlc_converts_to(V2,V)::check();
- }
-
- template <typename Tag, typename V>
- template <typename Tag2, typename V2>
- inline
- object_id<Tag,V>::object_id(const object_id<Tag2,V2>& id)
- {
- typedef object_id<Tag2,V2> id_t;
- mlc_abort(id_t)::check();
- }
-
- template <typename Tag, typename V>
- template <typename V2>
- inline
- object_id<Tag,V>&
- object_id<Tag,V>::operator=(const V2& v)
- {
- mlc_converts_to(V2,V)::check();
-
- id_ = v;
- return *this;
- }
-
- template <typename Tag, typename V>
- inline
- V&
- object_id<Tag,V>::value()
- {
- return id_;
- }
-
- template <typename Tag, typename V>
- inline
- const V&
- object_id<Tag,V>::value() const
- {
- return id_;
- }
-
- template <typename Tag, typename V>
- inline
- object_id<Tag,V>::operator unsigned() const
- {
- return id_;
- }
-
-
- template <typename Tag, typename V>
- inline
- bool
- object_id<Tag,V>::is_valid() const
- {
- return id_ != mln_max(V);
- }
-
- template <typename Tag, typename V>
- inline
- void
- object_id<Tag,V>::invalidate()
- {
- id_ = mln_max(V);
- }
-
- template <typename Tag, typename V>
- inline
- unsigned
- object_id<Tag,V>::to_equiv() const
- {
- return id_;
- }
-
-
-
-
- template <typename Tag, typename V>
- inline
- bool
- operator==(const object_id<Tag,V>& lhs, const object_id<Tag,V>& rhs)
- {
- return lhs.value() == rhs.value();
- }
-
- template <typename Tag, typename V, typename V2>
- inline
- bool
- operator==(const object_id<Tag,V>& lhs, const Value<V2>& rhs)
- {
- return lhs.value() == exact(rhs).to_equiv();
- }
-
-# endif // ! MLN_INCLUDE_ONLY
-
-
-} // end of namespace mln
-
-#endif // ! MLN_CORE_CONCEPT_OBJECT_ID_HH
-
diff --git a/milena/mln/util/graph_ids.hh b/milena/mln/util/graph_ids.hh
index df3e981..2f9eab5 100644
--- a/milena/mln/util/graph_ids.hh
+++ b/milena/mln/util/graph_ids.hh
@@ -33,7 +33,7 @@
///
/// Definition of graph element ids.
-# include <mln/core/concept/object_id.hh>
+# include <mln/util/object_id.hh>
namespace mln
diff --git a/milena/mln/util/object_id.hh b/milena/mln/util/object_id.hh
new file mode 100644
index 0000000..b3ea879
--- /dev/null
+++ b/milena/mln/util/object_id.hh
@@ -0,0 +1,213 @@
+// 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.
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+
+#ifndef MLN_UTIL_OBJECT_ID_HH
+# define MLN_UTIL_OBJECT_ID_HH
+
+/// \file mln/core/concept/object_id.hh
+///
+/// Base class of an object id.
+
+
+# include <mln/core/concept/object.hh>
+# include <mln/value/concept/integer.hh>
+# include <mln/metal/abort.hh>
+
+namespace mln
+{
+
+ namespace util
+ {
+
+ /// Base class of an object id.
+ /// \tparam Tag the tag type
+ /// \tparam Equiv the equivalent value.
+ template <typename Tag, typename V>
+ class object_id : public value::Integer< object_id<Tag, V> >
+ {
+ public:
+ /// The underlying type id.
+ typedef V value_t;
+ typedef unsigned equiv;
+ typedef V enc;
+
+ /// Constructors
+ /// @{
+ object_id();
+
+ template <typename V2>
+ object_id(const V2& id);
+
+ template <typename Tag2, typename V2>
+ object_id(const object_id<Tag2,V2>& other);
+ /// @}
+
+ template <typename V2>
+ object_id<Tag,V>& operator=(const V2& e);
+
+ const V& value() const;
+ V& value();
+
+ operator unsigned() const;
+
+ bool is_valid() const;
+ void invalidate();
+
+ unsigned to_equiv() const;
+
+ protected:
+ V id_;
+ };
+
+
+ template <typename Tag, typename V>
+ bool
+ operator==(const object_id<Tag,V>& lhs, const object_id<Tag,V>& rhs);
+
+ template <typename Tag, typename V, typename V2>
+ bool
+ operator<(const object_id<Tag,V>& lhs, const object_id<Tag,V>& rhs);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename Tag, typename V>
+ inline
+ object_id<Tag,V>::object_id()
+ : id_(mln_max(V))
+ {
+ }
+
+ template <typename Tag, typename V>
+ template <typename V2>
+ inline
+ object_id<Tag,V>::object_id(const V2& id)
+ : id_(id)
+ {
+ mlc_converts_to(V2,V)::check();
+ }
+
+ template <typename Tag, typename V>
+ template <typename Tag2, typename V2>
+ inline
+ object_id<Tag,V>::object_id(const object_id<Tag2,V2>& id)
+ {
+ typedef object_id<Tag2,V2> id_t;
+ mlc_abort(id_t)::check();
+ }
+
+ template <typename Tag, typename V>
+ template <typename V2>
+ inline
+ object_id<Tag,V>&
+ object_id<Tag,V>::operator=(const V2& v)
+ {
+ mlc_converts_to(V2,V)::check();
+
+ id_ = v;
+ return *this;
+ }
+
+ template <typename Tag, typename V>
+ inline
+ V&
+ object_id<Tag,V>::value()
+ {
+ return id_;
+ }
+
+ template <typename Tag, typename V>
+ inline
+ const V&
+ object_id<Tag,V>::value() const
+ {
+ return id_;
+ }
+
+ template <typename Tag, typename V>
+ inline
+ object_id<Tag,V>::operator unsigned() const
+ {
+ return id_;
+ }
+
+
+ template <typename Tag, typename V>
+ inline
+ bool
+ object_id<Tag,V>::is_valid() const
+ {
+ return id_ != mln_max(V);
+ }
+
+ template <typename Tag, typename V>
+ inline
+ void
+ object_id<Tag,V>::invalidate()
+ {
+ id_ = mln_max(V);
+ }
+
+ template <typename Tag, typename V>
+ inline
+ unsigned
+ object_id<Tag,V>::to_equiv() const
+ {
+ return id_;
+ }
+
+
+
+
+ template <typename Tag, typename V>
+ inline
+ bool
+ operator==(const object_id<Tag,V>& lhs, const object_id<Tag,V>& rhs)
+ {
+ return lhs.value() == rhs.value();
+ }
+
+ template <typename Tag, typename V>
+ inline
+ bool
+ operator<(const object_id<Tag,V>& lhs, const object_id<Tag,V>& rhs)
+ {
+ return lhs.value() < rhs.value();
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::util
+
+} // end of namespace mln
+
+#endif // ! MLN_UTIL_OBJECT_ID_HH
+
--
1.6.1.2
1
0
* 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.5.6.5
1
0
* 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
1
0