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
June 2012
- 6 participants
- 147 discussions
* src/contest/DAE-2011/README,
* src/contest/hdibco-2010/README,
* src/contest/hdlac-2011/README: New.
---
scribo/ChangeLog | 8 ++++++++
scribo/src/contest/DAE-2011/README | 23 +++++++++++++++++++++++
scribo/src/contest/hdibco-2010/README | 21 +++++++++++++++++++++
scribo/src/contest/hdlac-2011/README | 26 ++++++++++++++++++++++++++
4 files changed, 78 insertions(+), 0 deletions(-)
create mode 100644 scribo/src/contest/DAE-2011/README
create mode 100644 scribo/src/contest/hdibco-2010/README
create mode 100644 scribo/src/contest/hdlac-2011/README
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 1ca4fbb..6a68f43 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,13 @@
2012-05-10 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Add Readme files about contests.
+
+ * src/contest/DAE-2011/README,
+ * src/contest/hdibco-2010/README,
+ * src/contest/hdlac-2011/README: New.
+
+2012-05-10 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Fix compilation in Scribo.
* scribo/primitive/link/merge_double_link_closest_aligned.hh: Add
diff --git a/scribo/src/contest/DAE-2011/README b/scribo/src/contest/DAE-2011/README
new file mode 100644
index 0000000..c267363
--- /dev/null
+++ b/scribo/src/contest/DAE-2011/README
@@ -0,0 +1,23 @@
+ -*- outline -*-
+
+* Conference
+ICDAR 2011
+
+* Contest
+Document Analysis Algorithm Contributions in End-to-End Applications
+
+* Description
+This contest aims to provide a metric giving indications on the
+influence of individual specific document analysis tools to overall
+end-to-end applications. Contestants are provided with a full, working
+pipeline operating on a raw document page image and proceeding to
+extract some final information. The pipeline is built with clearly
+identified analysis stages (e.g. binarization, skew detection, layout
+analysis, OCR ...) that have a formalized input and
+output. Contestants are invited to contribute their own algorithms as
+an alternative to one or more of the initially provided stages and
+evaluation will be done on the overall impact of the contributed
+algorithm to the final (end of pipeline) result.
+
+* Paper
+http://hal.inria.fr/inria-00608371/
diff --git a/scribo/src/contest/hdibco-2010/README b/scribo/src/contest/hdibco-2010/README
new file mode 100644
index 0000000..d703113
--- /dev/null
+++ b/scribo/src/contest/hdibco-2010/README
@@ -0,0 +1,21 @@
+ -*- outline -*-
+
+* Conference
+12th Internation Conference on Frontiers in Handwriting Recognition
+(ICFHR 2010)
+
+* Contest
+Handwritten Document Image Binarization Contest
+
+* Description
+In H-DIBCO 2010 (Handwritten Document Image Binarization Contest), the
+general objective is to record recent advances in handwritten document
+image binarization using established evaluation performance
+measures. We will create a benchmarking dataset that is representative
+of the potential problems which are challenging in the binarization
+process and use a common evaluation platform in order to test and
+compare the submitted algorithms for handwritten document image
+binarization.
+
+* Paper
+http://users.iit.demokritos.gr/~bgat/HDIBCO2010.pdf
diff --git a/scribo/src/contest/hdlac-2011/README b/scribo/src/contest/hdlac-2011/README
new file mode 100644
index 0000000..5576882
--- /dev/null
+++ b/scribo/src/contest/hdlac-2011/README
@@ -0,0 +1,26 @@
+ -*- outline -*-
+
+* Conference
+ICDAR 2011
+
+* Contest
+Historical Document Layout Analysis Competition
+
+* Description
+This paper presents an objective comparative evaluation of layout
+analysis methods for scanned historical documents. It describes the
+competition (modus operandi, dataset and evaluation methodology) held
+in the context of ICDAR2011 and the International Workshop on
+Historical Document Imaging and Processing (HIP2011), presenting the
+results of the evaluation of four submitted methods. A commercial
+state-of-the-art system is also evaluated for comparison. Two
+scenarios are reported in this paper, one evaluating the ability of
+methods to accurately segment regions and the other evaluating the
+whole pipeline of segmentation and region classification (with a text
+extraction goal). The results indicate that there is a convergence to
+a certain methodology with some variations in the approach. However,
+there is still a considera-ble need to develop robust methods that
+deal with the idiosyn-crasies of historical documents.
+
+* Paper
+http://www.primaresearch.org/ICDAR2011_competition
--
1.7.2.5
1
0
* scribo/primitive/link/merge_double_link_closest_aligned.hh: Add
a missing include.
* src/content_in_hdoc.cc,
* src/contest/DAE-2011/content_in_doc_dae.cc,
* src/contest/DAE-2011/content_in_hdoc_dae.cc,
* src/contest/hdlac-2011/content_in_hdoc_hdlac.cc,
* src/non_text_components.cc: Add mandatory arguments.
---
scribo/ChangeLog | 13 +++++++++++++
.../link/merge_double_link_closest_aligned.hh | 4 +++-
scribo/src/content_in_hdoc.cc | 7 ++++---
scribo/src/contest/DAE-2011/content_in_doc_dae.cc | 5 +++--
scribo/src/contest/DAE-2011/content_in_hdoc_dae.cc | 5 +++--
.../contest/hdlac-2011/content_in_hdoc_hdlac.cc | 10 ++++++----
scribo/src/non_text_components.cc | 5 +++--
7 files changed, 35 insertions(+), 14 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 1122e11..1ca4fbb 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,3 +1,16 @@
+2012-05-10 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Fix compilation in Scribo.
+
+ * scribo/primitive/link/merge_double_link_closest_aligned.hh: Add
+ a missing include.
+
+ * src/content_in_hdoc.cc,
+ * src/contest/DAE-2011/content_in_doc_dae.cc,
+ * src/contest/DAE-2011/content_in_hdoc_dae.cc,
+ * src/contest/hdlac-2011/content_in_hdoc_hdlac.cc,
+ * src/non_text_components.cc: Add mandatory arguments.
+
2012-05-07 Guillaume Lazzara <z(a)lrde.epita.fr>
* scribo/debug/logger.hh: Improve log system.
diff --git a/scribo/scribo/primitive/link/merge_double_link_closest_aligned.hh b/scribo/scribo/primitive/link/merge_double_link_closest_aligned.hh
index d80fe85..a6143c8 100644
--- a/scribo/scribo/primitive/link/merge_double_link_closest_aligned.hh
+++ b/scribo/scribo/primitive/link/merge_double_link_closest_aligned.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2011, 2012 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -31,6 +32,7 @@
# define SCRIBO_PRIMITIVE_LINK_MERGE_DOUBLE_LINK_CLOSEST_ALIGNED_HH
+# include <mln/util/couple.hh>
# include <scribo/core/macros.hh>
# include <scribo/core/object_links.hh>
# include <scribo/core/tag/anchor.hh>
diff --git a/scribo/src/content_in_hdoc.cc b/scribo/src/content_in_hdoc.cc
index 737b1d3..650c436 100644
--- a/scribo/src/content_in_hdoc.cc
+++ b/scribo/src/content_in_hdoc.cc
@@ -1,5 +1,5 @@
-// Copyright (C) 2010, 2011 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2010, 2011, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -118,7 +118,8 @@ int main(int argc, char* argv[])
std::cout << "Using K = " << K << std::endl;
}
- input_preproc = toolchain::text_in_doc_preprocess(input, false, K);
+ input_preproc = toolchain::text_in_doc_preprocess(input, false, K,
+ false, false);
// Cleanup components on borders
{
diff --git a/scribo/src/contest/DAE-2011/content_in_doc_dae.cc b/scribo/src/contest/DAE-2011/content_in_doc_dae.cc
index d194bd1..9d5034f 100644
--- a/scribo/src/contest/DAE-2011/content_in_doc_dae.cc
+++ b/scribo/src/contest/DAE-2011/content_in_doc_dae.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2011 EPITA Research and Development Laboratory
+// Copyright (C) 2011, 2012 EPITA Research and Development Laboratory
// (LRDE)
//
// This file is part of Olena.
@@ -80,7 +80,8 @@ int main(int argc, char* argv[])
// Preprocess document
image2d<bool> input_preproc;
- input_preproc = toolchain::text_in_doc_preprocess(input, false, 0.34);
+ input_preproc = toolchain::text_in_doc_preprocess(input, false, 0.34,
+ false, false);
bool denoise = true;
std::string language = "";
diff --git a/scribo/src/contest/DAE-2011/content_in_hdoc_dae.cc b/scribo/src/contest/DAE-2011/content_in_hdoc_dae.cc
index 5986142..c3dad6c 100644
--- a/scribo/src/contest/DAE-2011/content_in_hdoc_dae.cc
+++ b/scribo/src/contest/DAE-2011/content_in_hdoc_dae.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2011 EPITA Research and Development Laboratory
+// Copyright (C) 2011, 2012 EPITA Research and Development Laboratory
// (LRDE)
//
// This file is part of Olena.
@@ -91,7 +91,8 @@ int main(int argc, char* argv[])
// Preprocess document
image2d<bool> input_preproc;
{
- input_preproc = toolchain::text_in_doc_preprocess(input, false, 0.34);
+ input_preproc = toolchain::text_in_doc_preprocess(input, false, 0.34,
+ false, false);
// Cleanup components on borders
{
diff --git a/scribo/src/contest/hdlac-2011/content_in_hdoc_hdlac.cc b/scribo/src/contest/hdlac-2011/content_in_hdoc_hdlac.cc
index c00b70f..deb5bdd 100644
--- a/scribo/src/contest/hdlac-2011/content_in_hdoc_hdlac.cc
+++ b/scribo/src/contest/hdlac-2011/content_in_hdoc_hdlac.cc
@@ -1,5 +1,5 @@
-// Copyright (C) 2010, 2011 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2010, 2011, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -90,7 +90,8 @@ int main(int argc, char* argv[])
// Preprocess document
image2d<bool> input_preproc;
{
- input_preproc = toolchain::text_in_doc_preprocess(input, false, 0, 0.34);
+ input_preproc = toolchain::text_in_doc_preprocess(input, false, 0, 0.34,
+ false, false);
// Cleanup components on borders
{
@@ -106,7 +107,8 @@ int main(int argc, char* argv[])
|| bbox(e).pmax().row() == b.pmax().row()
|| bbox(e).pmin().col() == b.pmin().col()
|| bbox(e).pmax().col() == b.pmax().col())
- data::fill(((input_preproc | bbox(e)).rw() | (pw::value(lbl) == pw::cst(e))).rw(), false);
+ data::fill(((input_preproc | bbox(e)).rw()
+ | (pw::value(lbl) == pw::cst(e))).rw(), false);
}
}
diff --git a/scribo/src/non_text_components.cc b/scribo/src/non_text_components.cc
index 38a4e5e..27884f8 100644
--- a/scribo/src/non_text_components.cc
+++ b/scribo/src/non_text_components.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2011 EPITA Research and Development Laboratory
+// Copyright (C) 2011, 2012 EPITA Research and Development Laboratory
// (LRDE)
//
// This file is part of Olena.
@@ -93,7 +93,8 @@ int main(int argc, char* argv[])
// Preprocess document
image2d<bool>
- input_preproc = toolchain::text_in_doc_preprocess(input, false, 0.34);
+ input_preproc = toolchain::text_in_doc_preprocess(input, false, 0.34,
+ false, false);
bool denoise = true;
--
1.7.2.5
1
0
olena-2.0-65-ge1b3bd7 Rely on Argument-Dependent Lookup (ADL) in from_to_ overloads.
by Guillaume Lazzara 22 Jun '12
by Guillaume Lazzara 22 Jun '12
22 Jun '12
* mln/accu/count_labels.hh,
* mln/convert/from_to.hxx ,
* mln/convert/to.hh,
* mln/core/alias/point1d.hh,
* mln/core/alias/point2d.hh,
* mln/core/alias/point3d.hh,
* mln/core/dpoint.hh,
* mln/core/internal/neighborhood_base.hh,
* mln/core/point.hh,
* mln/core/site_set/p_centered.hh,
* mln/core/site_set/p_vaccess.hh,
* mln/fun/v2v/hsl_to_rgb.hh,
* mln/fun/v2v/rgb_to_hsl.hh,
* mln/io/magick/save.hh,
* mln/io/plot/save.hh,
* mln/labeling/blobs_and_compute.hh,
* mln/labeling/value_and_compute.hh,
* mln/make/w_window2d.hh,
* mln/win/multiple.hh,
* mln/win/multiple_size.hh,
* tests/accu/site_set/rectangularity.cc,
* tests/core/other/graph_elt_neighborhood.cc,
* tests/core/other/graph_elt_window.cc,
* tests/core/other/point_set_compatibility.cc,
* tests/draw/graph.cc: Update forward declarations and includes.
* mln/algebra/vec.hh,
* mln/convert/from_to.hh,
* mln/convert/impl/from_double_to_value.hh,
* mln/convert/impl/from_float_to_value.hh,
* mln/convert/impl/from_image_to_site_set.hh,
* mln/convert/impl/from_int_to_value.hh,
* mln/convert/impl/from_unsigned_to_value.hh,
* mln/convert/impl/from_value_to_value.hh,
* mln/core/alias/neighb2d.hh,
* mln/core/alias/neighb3d.hh,
* mln/core/alias/window1d.hh,
* mln/core/alias/window2d.hh,
* mln/core/alias/window3d.hh,
* mln/core/concept/accumulator.hh,
* mln/core/concept/gdpoint.hh,
* mln/core/concept/gpoint.hh,
* mln/core/concept/image.hh,
* mln/core/concept/proxy.hh,
* mln/core/concept/site_set.hh,
* mln/core/concept/window.hh,
* mln/core/image/graph_window_if_piter.hh,
* mln/core/image/image1d.hh,
* mln/core/mixed_neighb.hh,
* mln/core/neighb.hh,
* mln/core/site_set/operators.hh,
* mln/core/w_window.hh,
* mln/fun/i2v/array.hh,
* mln/util/object_id.hh,
* mln/value/hsl.hh,
* mln/value/int_u.hh,
* mln/value/label.hh,
* mln/value/qt/rgb32.hh,
* mln/value/rgb.hh,
* mln/histo/array.hh,
* mln/util/array.hh: Move from_to_ overloads in the same namespace
as their first argument.
---
milena/ChangeLog | 67 +++
milena/mln/accu/count_labels.hh | 4 +-
milena/mln/algebra/vec.hh | 165 +++++++-
milena/mln/convert/from_to.hh | 130 +++---
milena/mln/convert/from_to.hxx | 441 +-------------------
milena/mln/convert/impl/from_double_to_value.hh | 159 ++++----
milena/mln/convert/impl/from_float_to_value.hh | 179 ++++----
milena/mln/convert/impl/from_image_to_site_set.hh | 8 +-
milena/mln/convert/impl/from_int_to_value.hh | 101 ++---
milena/mln/convert/impl/from_unsigned_to_value.hh | 140 +++----
milena/mln/convert/impl/from_value_to_value.hh | 7 +-
milena/mln/convert/to.hh | 1 -
milena/mln/core/alias/neighb2d.hh | 75 ++--
milena/mln/core/alias/neighb3d.hh | 51 +--
milena/mln/core/alias/point1d.hh | 5 +-
milena/mln/core/alias/point2d.hh | 5 +-
milena/mln/core/alias/point3d.hh | 5 +-
milena/mln/core/alias/window1d.hh | 51 +--
milena/mln/core/alias/window2d.hh | 100 ++---
milena/mln/core/alias/window3d.hh | 56 +--
milena/mln/core/concept/accumulator.hh | 70 +--
milena/mln/core/concept/gdpoint.hh | 60 +--
milena/mln/core/concept/gpoint.hh | 122 ++----
milena/mln/core/concept/image.hh | 89 ++--
milena/mln/core/concept/proxy.hh | 53 +--
milena/mln/core/concept/site_set.hh | 113 +++---
milena/mln/core/concept/window.hh | 109 ++---
milena/mln/core/dpoint.hh | 1 -
milena/mln/core/image/graph_window_if_piter.hh | 4 +-
milena/mln/core/image/image1d.hh | 65 +---
milena/mln/core/internal/neighborhood_base.hh | 9 +-
milena/mln/core/mixed_neighb.hh | 72 ++--
milena/mln/core/neighb.hh | 76 ++---
milena/mln/core/point.hh | 172 ++-------
milena/mln/core/site_set/operators.hh | 13 +-
milena/mln/core/site_set/p_centered.hh | 5 +-
milena/mln/core/site_set/p_vaccess.hh | 4 +-
milena/mln/core/w_window.hh | 191 +++------
milena/mln/fun/i2v/array.hh | 154 +++----
milena/mln/fun/v2v/hsl_to_rgb.hh | 10 +-
milena/mln/fun/v2v/rgb_to_hsl.hh | 4 +-
milena/mln/histo/array.hh | 34 ++-
milena/mln/io/magick/save.hh | 8 +-
milena/mln/io/plot/save.hh | 5 +-
milena/mln/labeling/blobs_and_compute.hh | 5 +-
milena/mln/labeling/value_and_compute.hh | 5 +-
milena/mln/make/w_window2d.hh | 5 +-
milena/mln/util/array.hh | 138 ++++---
milena/mln/util/object_id.hh | 46 +--
milena/mln/value/hsl.hh | 104 +++---
milena/mln/value/int_u.hh | 168 ++++----
milena/mln/value/label.hh | 152 +++----
milena/mln/value/qt/rgb32.hh | 78 +---
milena/mln/value/rgb.hh | 196 ++++------
milena/mln/win/multiple.hh | 5 +-
milena/mln/win/multiple_size.hh | 3 +-
milena/tests/accu/site_set/rectangularity.cc | 4 +-
milena/tests/core/other/graph_elt_neighborhood.cc | 3 +-
milena/tests/core/other/graph_elt_window.cc | 5 +-
milena/tests/core/other/point_set_compatibility.cc | 4 +-
milena/tests/draw/graph.cc | 4 +-
61 files changed, 1623 insertions(+), 2495 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index c5146c0..96019b5 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,70 @@
+2012-05-10 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Rely on Argument-Dependent Lookup (ADL) in from_to_ overloads.
+
+ * mln/accu/count_labels.hh,
+ * mln/convert/from_to.hxx ,
+ * mln/convert/to.hh,
+ * mln/core/alias/point1d.hh,
+ * mln/core/alias/point2d.hh,
+ * mln/core/alias/point3d.hh,
+ * mln/core/dpoint.hh,
+ * mln/core/internal/neighborhood_base.hh,
+ * mln/core/point.hh,
+ * mln/core/site_set/p_centered.hh,
+ * mln/core/site_set/p_vaccess.hh,
+ * mln/fun/v2v/hsl_to_rgb.hh,
+ * mln/fun/v2v/rgb_to_hsl.hh,
+ * mln/io/magick/save.hh,
+ * mln/io/plot/save.hh,
+ * mln/labeling/blobs_and_compute.hh,
+ * mln/labeling/value_and_compute.hh,
+ * mln/make/w_window2d.hh,
+ * mln/win/multiple.hh,
+ * mln/win/multiple_size.hh,
+ * tests/accu/site_set/rectangularity.cc,
+ * tests/core/other/graph_elt_neighborhood.cc,
+ * tests/core/other/graph_elt_window.cc,
+ * tests/core/other/point_set_compatibility.cc,
+ * tests/draw/graph.cc: Update forward declarations and includes.
+
+ * mln/algebra/vec.hh,
+ * mln/convert/from_to.hh,
+ * mln/convert/impl/from_double_to_value.hh,
+ * mln/convert/impl/from_float_to_value.hh,
+ * mln/convert/impl/from_image_to_site_set.hh,
+ * mln/convert/impl/from_int_to_value.hh,
+ * mln/convert/impl/from_unsigned_to_value.hh,
+ * mln/convert/impl/from_value_to_value.hh,
+ * mln/core/alias/neighb2d.hh,
+ * mln/core/alias/neighb3d.hh,
+ * mln/core/alias/window1d.hh,
+ * mln/core/alias/window2d.hh,
+ * mln/core/alias/window3d.hh,
+ * mln/core/concept/accumulator.hh,
+ * mln/core/concept/gdpoint.hh,
+ * mln/core/concept/gpoint.hh,
+ * mln/core/concept/image.hh,
+ * mln/core/concept/proxy.hh,
+ * mln/core/concept/site_set.hh,
+ * mln/core/concept/window.hh,
+ * mln/core/image/graph_window_if_piter.hh,
+ * mln/core/image/image1d.hh,
+ * mln/core/mixed_neighb.hh,
+ * mln/core/neighb.hh,
+ * mln/core/site_set/operators.hh,
+ * mln/core/w_window.hh,
+ * mln/fun/i2v/array.hh,
+ * mln/util/object_id.hh,
+ * mln/value/hsl.hh,
+ * mln/value/int_u.hh,
+ * mln/value/label.hh,
+ * mln/value/qt/rgb32.hh,
+ * mln/value/rgb.hh,
+ * mln/histo/array.hh,
+ * mln/util/array.hh: Move from_to_ overloads in the same namespace
+ as their first argument.
+
2012-05-07 Guillaume Lazzara <z(a)lrde.epita.fr>
* mln/registration/icp.hh: Add a missing initialization.
diff --git a/milena/mln/accu/count_labels.hh b/milena/mln/accu/count_labels.hh
index 07c48b2..c81cc9c 100644
--- a/milena/mln/accu/count_labels.hh
+++ b/milena/mln/accu/count_labels.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2012 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -30,6 +31,7 @@
///
/// Define an accumulator that counts the number of different labels.
+# include <vector>
# include <mln/accu/internal/base.hh>
# include <mln/core/concept/meta_accumulator.hh>
# include <mln/metal/is_a.hh>
diff --git a/milena/mln/algebra/vec.hh b/milena/mln/algebra/vec.hh
index bbe23c8..772c46e 100644
--- a/milena/mln/algebra/vec.hh
+++ b/milena/mln/algebra/vec.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2006, 2008, 2009, 2011 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2006, 2008, 2009, 2011, 2012 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -69,6 +69,14 @@ namespace mln
mln_sum_product(C,C) l2(const algebra::vec<n,C>& vec);
}
+ namespace value {
+ template <unsigned n> struct rgb;
+ }
+
+ template <typename G, typename C> struct point;
+ template <typename E> struct Gpoint;
+ // end of forward declarations
+
namespace trait
{
@@ -261,6 +269,38 @@ namespace mln
vec& operator=(const mat<n, 1, U>& rhs);
};
+
+ /// \internal Conversion: vec -> rgb.
+ template <typename T, unsigned m>
+ void from_to_(const vec<3,T>& from, value::rgb<m>& to_);
+
+ /// \internal Conversion: vec<1,C1> -> point<G,C2>
+ template <typename C1, typename G, typename C2>
+ inline
+ void
+ from_to_(const vec<1,C1>& from, point<G,C2>& to);
+
+ /// \internal Conversion: vec<n,C1> -> point<G,C2>
+ template <unsigned n, typename C1, typename G, typename C2>
+ void
+ from_to_(const vec<n,C1>& from, point<G,C2>& to);
+
+ /// \internal Conversion: vec<1,C1> -> point<G,C1>
+ template <typename C1, typename G>
+ inline
+ void
+ from_to_(const vec<1,C1>& from, point<G,C1>& to);
+
+ /// \internal Conversion: vec<n,C1> -> point<G,C1>
+ template <unsigned n, typename C1, typename G>
+ void
+ from_to_(const vec<n,C1>& from, point<G,C1>& to);
+
+ /// \internal Conversion: vec -> gpoint
+ template <unsigned n, typename T, typename P>
+ void
+ from_to_(const vec<n,T>& from, Gpoint<P>& to);
+
} // end of namespace mln::algebra
@@ -434,6 +474,46 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
+ namespace internal
+ {
+
+ template <typename C, typename C2>
+ inline
+ C
+ convert_data_(metal::bool_<false>, const C2& v)
+ {
+ return static_cast<C>(v);
+ }
+
+ template <typename C, typename C2>
+ inline
+ C
+ convert_data_(metal::bool_<true>, const C2& v)
+ {
+ return static_cast<C>(round(v));
+ }
+
+ template <typename C, typename C2>
+ inline
+ C
+ convert_data(const C2& v)
+ {
+ // If (C != float && C != double) && (C2 == float || C2 == double)
+ // => We want to round the value.
+ // Otherwise we can just statically cast.
+ //
+ return convert_data_<C>(
+ typename mlc_and(
+ mlc_and(mlc_is_not(C,float),
+ mlc_is_not(C,double)),
+ mlc_or(mlc_is(C2,float),
+ mlc_is(C2, double)))::eval(), v);
+ }
+
+ } // end of namespace mln::internal
+
+
+
namespace algebra
{
@@ -733,6 +813,87 @@ namespace mln
}
+ // Conversions
+
+
+ template <typename T, unsigned m>
+ inline
+ void
+ from_to_(const vec<3,T>& from, value::rgb<m>& to)
+ {
+ algebra::vec<3, unsigned> tmp;
+ for (unsigned i = 0; i < 3; ++i)
+ tmp[i] = static_cast<unsigned>(from[i]); // FIXME: Use from_to_ instead of cast.
+
+ to = value::rgb<m>(tmp);
+ }
+
+ template <unsigned n, typename C1, typename G, typename C2>
+ inline
+ void
+ from_to_(const mln::algebra::vec<n,C1>& from, point<G,C2>& to)
+ {
+ mlc_converts_to(C1, C2)::check();
+ enum { dim = G::dim };
+ mlc_bool(G::dim == n)::check();
+
+ unsigned j = 0;
+ for (unsigned i = dim - 2; i < dim; ++i)
+ to[i] = mln::internal::convert_data<C2>(from[j++]);
+ for (unsigned i = 2; i < dim; ++i, ++j)
+ to[i-j] = mln::internal::convert_data<C2>(from[j]);
+ }
+
+ template <typename C1, typename G, typename C2>
+ inline
+ void
+ from_to_(const mln::algebra::vec<1,C1>& from, point<G,C2>& to)
+ {
+ mlc_converts_to(C1, C2)::check();
+ enum { dim = G::dim };
+ mlc_bool(G::dim == 1)::check();
+
+ to[0] = mln::internal::convert_data<C2>(from[0]);
+ }
+
+ template <unsigned n, typename C1, typename G>
+ inline
+ void
+ from_to_(const mln::algebra::vec<n,C1>& from, point<G,C1>& to)
+ {
+ enum { dim = G::dim };
+ mlc_bool(G::dim == n)::check();
+
+ unsigned j = 0;
+ for (unsigned i = dim - 2; i < dim; ++i)
+ to[i] = from[j++];
+ for (unsigned i = 2; i < dim; ++i, ++j)
+ to[i-j] = from[j];
+ }
+
+ template <typename C1, typename G>
+ inline
+ void
+ from_to_(const mln::algebra::vec<1,C1>& from, point<G,C1>& to)
+ {
+ enum { dim = G::dim };
+ mlc_bool(G::dim == 1)::check();
+
+ to[0] = from[0];
+ }
+
+ template <unsigned n, typename T, typename P>
+ inline
+ void
+ from_to_(const vec<n,T>& from, Gpoint<P>& to_)
+ {
+ mlc_bool(P::dim == n)::check();
+ P& to = exact(to_);
+ for (unsigned i = 0; i < n; ++i)
+ to[i] = static_cast< typename P::coord >(from[i]); // FIXME: cast -> best effort...
+ }
+
+
} // end of namespace mln::algebra
diff --git a/milena/mln/convert/from_to.hh b/milena/mln/convert/from_to.hh
index 1b04847..272a47d 100644
--- a/milena/mln/convert/from_to.hh
+++ b/milena/mln/convert/from_to.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008, 2009, 2010 EPITA Research and Development
+// Copyright (C) 2008, 2009, 2010, 2012 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -38,7 +38,6 @@
/// \todo Find a solution for g++-2.95 and '...'; see FIXME below.
# include <mln/convert/impl/all.hh>
-# include <mln/convert/from_to.hxx>
# include <mln/metal/abort.hh>
# include <mln/metal/converts_to.hh>
@@ -64,8 +63,71 @@ namespace mln
from_to(const F& from, T& to);
+ } // end of namespace mln::convert
+
+} // end of namespace mln
+
+
# ifndef MLN_INCLUDE_ONLY
+// Exact same type.
+template <typename T>
+inline
+void
+from_to_(const T& from, T& to)
+{
+ to = from;
+}
+
+
+// Default conversion.
+template <typename F, typename T>
+inline
+void
+from_to_(const F& from, T& to)
+{
+ to = mln::value::cast<T>(from);
+}
+
+
+namespace mln
+{
+
+ // Exact same type.
+ template <typename T>
+ inline
+ void
+ from_to_(const T& from, T& to)
+ {
+ to = from;
+ }
+
+ // Object -> Object (F not convertible towards T)
+ // No conversion exists!
+ template <typename F, typename T>
+ void
+ from_to_(const Object<F>&, Object<T>&)
+ {
+ // This particular from-to is not defined!
+ //
+ // Either this conversion is meaningless or an overload is
+ // missing.
+ mlc_abort(F)::check();
+ }
+
+
+ // Object -> Object
+ template <typename T>
+ inline
+ void
+ from_to_(const Object<T>& from, Object<T>& to)
+ {
+ exact(to) = exact(from);
+ }
+
+ namespace convert
+ {
+
namespace internal
{
@@ -128,7 +190,7 @@ namespace mln
from_to_dispatch(metal::false_,
const Object<F>& from, Object<T>& to)
{
- over_load::from_to_(exact(from), exact(to));
+ from_to_(exact(from), exact(to));
}
@@ -158,7 +220,7 @@ namespace mln
from_to_dispatch(metal::false_, const F& from,
metal::false_, T& to)
{
- over_load::from_to_(from, to);
+ from_to_(from, to);
}
@@ -169,7 +231,7 @@ namespace mln
from_to_dispatch(metal::true_, const F& from,
metal::false_, T& to)
{
- over_load::from_to_(exact(from), to);
+ from_to_(exact(from), to);
}
@@ -180,7 +242,7 @@ namespace mln
from_to_dispatch(metal::false_, const F& from,
metal::true_, T& to)
{
- over_load::from_to_(from, exact(to));
+ from_to_(from, exact(to));
}
// Object -> Object
@@ -197,58 +259,6 @@ namespace mln
} // end of namespace mln::convert::internal
- namespace over_load
- {
-
-
- // Object -> Object (F not convertible towards T)
- // No conversion exists!
- template <typename F, typename T>
- void
- from_to_(const Object<F>&, Object<T>&)
- {
- // This particular from-to is not defined!
- //
- // Either this conversion is meaningless or an overload is
- // missing.
- mlc_abort(F)::check();
- }
-
-
- // Object -> Object
- template <typename T>
- inline
- void
- from_to_(const Object<T>& from, Object<T>& to)
- {
- exact(to) = exact(from);
- }
-
-
- // Exact same type.
- template <typename T>
- inline
- void
- from_to_(const T& from, T& to)
- {
- to = from;
- }
-
-
- // Default conversion.
- template <typename F, typename T>
- inline
- void
- from_to_(const F& from, T& to)
- {
- to = mln::value::cast<T>(from);
- }
-
-
- } // end of namespace mln::convert::over_load
-
-
-
// Facade
template <typename F, typename T>
@@ -263,11 +273,11 @@ namespace mln
}
-# endif // ! MLN_INCLUDE_ONLY
-
} // end of namespace mln::convert
} // end of namespace mln
+# endif // ! MLN_INCLUDE_ONLY
+
#endif // ! MLN_CONVERT_FROM_TO_HH
diff --git a/milena/mln/convert/from_to.hxx b/milena/mln/convert/from_to.hxx
index a0e22df..81bc108 100644
--- a/milena/mln/convert/from_to.hxx
+++ b/milena/mln/convert/from_to.hxx
@@ -1,5 +1,5 @@
-// Copyright (C) 2008, 2009, 2010, 2011 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2008, 2009, 2010, 2011, 2012 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -29,78 +29,9 @@
/// \internal \file mln/convert/from_to.hxx
-// All overloaded "convert::from_to" routines have to be declared in
-// the present file. It allows for *deferred* use of these routines.
-
-# include <mln/core/def/all.hh>
-# include <mln/core/grids.hh>
-# include <mln/util/couple.hh>
-
-//FIXME: have a forward declaration.
-# include <vector>
-# include <set>
-
-
namespace mln
{
-
- // Forward declarations.
-
- template <typename E> struct Accumulator;
- template <typename E> struct Gdpoint;
- template <typename E> struct Gpoint;
- template <typename E> struct Image;
- template <typename E> struct Object;
- template <typename E> struct Proxy;
- template <typename E> struct Site_Set;
- template <typename E> struct Value;
- template <typename E> struct Weighted_Window;
- template <typename E> struct Window;
-
- template <typename G, typename C> struct dpoint;
- template <typename G, typename C> struct point;
-
- template <typename D> class neighb;
- template <typename D> class window;
- template <typename D, typename W> struct w_window;
-
- template <typename T> struct image1d;
-
- namespace algebra {
- template <unsigned n, typename T> class vec;
- template <unsigned d, typename C> class h_vec;
- }
-
- namespace fun {
- namespace i2v {
- template <typename T> class array;
- }
- }
-
- namespace histo {
- template <typename T> struct array;
- }
-
- namespace util {
- template <typename T> class array;
- template <typename Tag, typename V> class object_id;
- }
-
- namespace value {
- namespace qt { struct rgb32; }
- template <unsigned n> struct rgb;
- template <typename H, typename S, typename L> class hsl_;
- template <unsigned n> struct int_u;
- template <unsigned n> struct label;
- }
-
- // end of Forward declarations.
-
-
-
- // convert::to
-
namespace convert
{
@@ -108,378 +39,10 @@ namespace mln
T
to(const O& from);
- } // end of namespace mln::convert
-
-
-
- // convert::from_to
-
- namespace convert
- {
-
- // Facade
-
template <typename F, typename T>
void
from_to(const F& from, T& to);
-
- namespace over_load
- {
-
- // Guard.
- template <typename F, typename T>
- void
- from_to_(const Object<F>&, Object<T>&);
- // end of Guard.
-
- // Object -> Object
- template <typename T>
- void
- from_to_(const Object<T>& from, Object<T>& to);
-
- // Object -> Object
- template <typename T>
- void
- from_to_(const T& from, T& to);
-
- // point -> point.
- template <typename G, typename C1, typename C2>
- inline
- void
- from_to_(const point<G,C1>& from, point<G,C2>& to);
-
- // algebra::vec -> point
- template <unsigned n, typename C1, typename G, typename C2>
- void
- from_to_(const algebra::vec<n,C1>& from, point<G,C2>& to);
-
- // algebra::vec -> point
- template <unsigned n, typename C1, typename G>
- void
- from_to_(const algebra::vec<n,C1>& from, point<G,C1>& to);
-
- // algebra::vec -> Gpoint.
- template <unsigned n, typename T, typename P>
- void
- from_to_(const algebra::vec<n,T>& from, Gpoint<P>& to_);
-
- // algebra::vec -> rgb.
- template <typename T, unsigned m>
- void
- from_to_(const algebra::vec<3,T>& from, value::rgb<m>& to);
-
-
- // bool -> rgb.
- template <unsigned m>
- void
- from_to_(bool from, value::rgb<m>& to);
-
- // rgb32 -> bool
- void
- from_to_(const value::qt::rgb32& from, bool& to);
-
- // bool -> rgb32
- void
- from_to_(const bool& from, value::qt::rgb32& to);
-
- // int_u -> rgb.
- template <unsigned m>
- void from_to_(const value::int_u<m>& from, value::rgb<m>& to);
-
- // int_u -> qt::rgb32.
- template <unsigned m>
- void from_to_(const value::int_u<m>& from, value::qt::rgb32& to);
-
- // int_u -> label
- template <unsigned n>
- void from_to_(const value::int_u<n>& from, value::label<n>& to_);
-
- // int_u -> unsigned
- template <unsigned n>
- void from_to_(const value::int_u<n>& from, unsigned& to_);
-
- // int_u -> bool.
- template <unsigned n>
- void
- from_to_(const value::int_u<n>& from, bool& to_);
-
- // int_u -> float
- template <unsigned n>
- void from_to_(const value::int_u<n>& from, float& to_);
-
- // int_u -> double
- template <unsigned n>
- void from_to_(const value::int_u<n>& from, double& to_);
-
- // label -> int_u.
- template <unsigned n>
- void
- from_to_(const value::label<n>& from, value::int_u<n>& to_);
-
- // label -> bool
- template <unsigned n>
- void from_to_(const value::label<n>& from, bool& to_);
-
- // int_u<n> -> label<m> with n < m
- template <unsigned n, unsigned m>
- void
- from_to_(const value::int_u<n>& from, value::label<m>& to_);
-
- // hsl -> rgb8.
- template <typename H, typename S, typename L>
- void from_to_(const value::hsl_<H,S,L>&, value::rgb<8>& to);
-
- // hsl -> rgb16.
- template <typename H, typename S, typename L>
- void from_to_(const value::hsl_<H,S,L>&, value::rgb<16>& to);
-
- // hsl -> qt::rgb32.
- template <typename H, typename S, typename L>
- void from_to_(const value::hsl_<H,S,L>&, value::qt::rgb32& to);
-
- // rgb to hsl
- void
- from_to_(const value::rgb<16>& from, value::hsl_<float,float,float>& to);
-
- // rgb to hsl
- void
- from_to_(const value::rgb<8>& from, value::hsl_<float,float,float>& to);
-
- // rgb -> bool.
- template <unsigned m>
- void from_to_(const value::rgb<m>& from, bool& to);
-
-
- // C-array -> Image.
- template <typename V, unsigned S, typename I>
- void
- from_to_(const V (&values)[S], Image<I>& to);
-
- // C-array -> w_window
- template <typename V, unsigned S, typename D, typename W>
- void
- from_to_(const V (&weight)[S], w_window<D,W>& to);
-
-
- // C-array -> window2d
- template <unsigned S>
- void
- from_to_(const bool (&values)[S],
- window< dpoint<grid::square, def::coord> >& win);
-
- template <unsigned R, unsigned C>
- void
- from_to_(const bool (&values)[R][C],
- window< dpoint<grid::square, def::coord> >& win);
-
-
- // C-array -> window3d
- template <unsigned S>
- void
- from_to_(const bool (&values)[S],
- window< dpoint<grid::cube, def::coord> >& win);
-
-
- // C-array -> neighb2d
- template <unsigned S>
- void
- from_to_(const bool (&values)[S],
- neighb< window< dpoint<grid::square, def::coord> > >& nbh);
-
- template <unsigned R, unsigned C>
- void
- from_to_(bool const (&values)[R][C],
- neighb< window< dpoint<grid::square, def::coord> > >& nbh);
-
-
- // C-array -> neighb3d
- template <unsigned S>
- void
- from_to_(const bool (&values)[S],
- neighb< window< dpoint<grid::cube, def::coord> > >& nbh);
-
-
-
- // Gdpoint -> point
- template <typename D>
- void
- from_to_(const Gdpoint<D>& from, mln_site(D)& to);
-
-
- // Value -> Value
- template <typename F, typename T>
- void
- from_to_(const Value<F>& from, Value<T>& to);
-
- // double-> Value
- template <typename V>
- void
- from_to_(const double& from, Value<V>& to);
-
- // double-> unsigned
- void
- from_to_(const double& from, unsigned& to);
-
- // double-> int
- void
- from_to_(const double& from, int& to);
-
- // float -> Value
- template <typename V>
- void
- from_to_(const float& from, Value<V>& to);
-
- // float -> unsigned
- void
- from_to_(const float& from, unsigned& to);
-
- // float -> int
- void
- from_to_(const float& from, int& to);
-
- // int -> Value
- template <typename T>
- void
- from_to_(const int& from, Value<T>& to);
-
- // Proxy -> T
- template <typename P, typename T>
- void
- from_to_(const Proxy<P>& from, T& to);
-
-
- // Gpoint -> algebra::vec.
- template <typename P, unsigned n, typename T>
- void
- from_to_(const Gpoint<P>& from, algebra::vec<n,T>& to);
-
- // Gpoint -> delta-point
- template <typename P>
- void
- from_to_(const Gpoint<P>& from, mln_delta(P)& to);
-
-
- // Image -> Site_Set.
- template <typename I, typename S>
- void
- from_to_(const Image<I>& from, Site_Set<S>& to);
-
- // Image -> w_window
- template <typename I, typename D, typename W>
- void
- from_to_(const Image<I>& from, w_window<D,W>& to);
-
-
- // neighb<W> -> W
- template <typename W>
- void
- from_to_(const mln::neighb<W>& from, W& to);
-
- // W -> neighb<W>
- template <typename W>
- void
- from_to_(const W& from, mln::neighb<W>& to);
-
-
- // Window -> Image
- template <typename W, typename I>
- void
- from_to_(const Window<W>& from, Image<I>& to);
-
-
- // w_window -> Image
- template <typename D, typename W, typename I>
- void
- from_to_(const w_window<D,W>& from, Image<I>& to);
-
-
-
- // util::array<T> -> fun::i2v::array<T>
- template <typename T>
- void
- from_to_(const util::array<T>& from, fun::i2v::array<T>& to);
-
- // util::array<T> -> fun::i2v::array<U>
- template <typename T, typename U>
- void
- from_to_(const util::array<T>& from, fun::i2v::array<U>& to);
-
- // std::vector<T> -> fun::i2v::array<T>
- template <typename T>
- void
- from_to_(const std::vector<T>& from, fun::i2v::array<T>& to);
-
- // std::vector<T> -> fun::i2v::array<U>
- template <typename T, typename U>
- void
- from_to_(const std::vector<T>& from, fun::i2v::array<U>& to);
-
- // util::array<T1> -> util::array<T2>
- template <typename T1, typename T2>
- void
- from_to_(const util::array<T1>& from, util::array<T2>& to);
-
-
-
- // util::array<T1> -> util::array<T2>
- template <typename T1, typename T2>
- void
- from_to_(const util::array<T1>& from, util::array<T2>& to);
-
- // fun::i2v::array<T1> -> util::array<T2>
- template <typename T1, typename T2>
- void
- from_to_(const fun::i2v::array<T1>& from, util::array<T2>& to);
-
-
- // Accumulator<A> -> mln_result(A)
- template <typename A>
- void
- from_to_(const Accumulator<A>& from, mln_result(A)& to);
-
-
-
- // Site_Set -> Image.
- template <typename S, typename I>
- void
- from_to_(const Site_Set<S>& from, Image<I>& to);
-
- // Site_Set -> std::set
- template <typename S, typename P, typename C_>
- void
- from_to_(const Site_Set<S>& from, std::set<P,C_>& to);
-
- // std::set -> Site_Set
- template <typename P, typename C_, typename S>
- void
- from_to_(const std::set<P,C_>& from, Site_Set<S>& to);
-
- // histo::array -> image1d
- template <typename V, typename T>
- void
- from_to_(const histo::array<V>& from, image1d<T>& to);
-
- // util::array -> image1d
- template <typename V, typename T>
- void
- from_to_(const util::array<V>& from, image1d<T>& to);
-
- // util::couple<T, U> -> util::couple<V, W>
- template <typename T, typename U, typename V, typename W>
- void
- from_to_(const util::couple<T, U>& from, util::couple<V, W>& to)
- {
- from_to(from.first(), to.first());
- from_to(from.second(), to.second());
- }
-
- // util::object_id<Tag,V> -> V.
- template <typename Tag, typename V>
- void from_to_(const util::object_id<Tag,V>& from, V& to_);
-
- } // end of namespace mln::convert::over_load
-
} // end of namespace mln::convert
} // end of namespace mln
diff --git a/milena/mln/convert/impl/from_double_to_value.hh b/milena/mln/convert/impl/from_double_to_value.hh
index fd2b32a..eaae734 100644
--- a/milena/mln/convert/impl/from_double_to_value.hh
+++ b/milena/mln/convert/impl/from_double_to_value.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2009, 2010, 2011 EPITA Research and Development
+// Copyright (C) 2009, 2010, 2011, 2012 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -45,113 +45,106 @@
namespace mln
{
+ /// \internal Conversion: double-> Value
+ template <typename V>
+ void from_to_(const double& from, Value<V>& to);
+
+ /// \internal Conversion: double-> unsigned
+ void from_to_(const double& from, unsigned& to);
+
+ /// \internal Conversion: double-> int
+ void from_to_(const double& from, int& to);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
namespace convert
{
- /// Conversion of a double \p from towards a value \p to.
+ namespace impl
+ {
+
+ // Case 1:
+
template <typename V>
+ inline
void
- from_to(const double& from, Value<V>& to);
-
+ from_double_to_value(const double& from,
+ mln::value::Integer<V>& to)
+ {
+ exact(to) = math::round<V>()(from);
+ }
-# ifndef MLN_INCLUDE_ONLY
+ // Case 2:
- namespace impl
+ template <typename V>
+ inline
+ void
+ from_double_to_value(const double& from,
+ mln::value::Floating<V>& to)
{
+ exact(to) = from;
+ }
- // Case 1:
-
- template <typename V>
- inline
- void
- from_double_to_value(const double& from,
- mln::value::Integer<V>& to)
- {
- exact(to) = math::round<V>()(from);
- }
- // Case 2:
+ // Default: no conversion defined.
- template <typename V>
- inline
- void
- from_double_to_value(const double& from,
- mln::value::Floating<V>& to)
- {
- exact(to) = from;
- }
+ template <typename V>
+ inline
+ void
+ from_double_to_value(const double& from,
+ Value<V>& to)
+ {
+ (void) from;
+ (void) to;
+ mlc_abort(V)::check();
+ }
+ } // end of namespace mln::convert::impl
- // Default: no conversion defined.
- template <typename V>
- inline
- void
- from_double_to_value(const double& from,
- Value<V>& to)
- {
- (void) from;
- (void) to;
- mlc_abort(V)::check();
- }
+ namespace internal
+ {
- } // end of namespace mln::convert::impl
+ template <typename V>
+ inline
+ void
+ from_double_to_value_dispatch(const double& from, Value<V>& to)
+ {
+ impl::from_double_to_value(from, exact(to));
+ }
+ } // end of namespace mln::convert::internal
- namespace internal
- {
+ } // end of namespace mln::convert
- template <typename V>
- inline
- void
- from_double_to_value_dispatch(const double& from, Value<V>& to)
- {
- impl::from_double_to_value(from, exact(to));
- }
- } // end of namespace mln::convert::internal
+ template <typename V>
+ inline
+ void
+ from_to_(const double& from, Value<V>& to)
+ {
+ convert::internal::from_double_to_value_dispatch(from, to);
+ }
+ inline
+ void
+ from_to_(const double& from, unsigned& to)
+ {
+ mln_precondition(from >= 0);
+ to = math::round<unsigned>()(from);
+ }
- namespace over_load
- {
+ inline
+ void
+ from_to_(const double& from, int& to)
+ {
+ to = math::round<int>()(from);
+ }
- // Facades.
-
-
- // double-> Value
- template <typename V>
- inline
- void
- from_to_(const double& from, Value<V>& to)
- {
- internal::from_double_to_value_dispatch(from, to);
- }
-
- // double-> unsigned
- inline
- void
- from_to_(const double& from,
- unsigned& to)
- {
- mln_precondition(from >= 0);
- to = math::round<unsigned>()(from);
- }
-
- // double-> int
- inline
- void
- from_to_(const double& from,
- int& to)
- {
- to = math::round<int>()(from);
- }
-
- } // end of namespace mln::convert::over_load
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace mln::convert
-
} // end of namespace mln
diff --git a/milena/mln/convert/impl/from_float_to_value.hh b/milena/mln/convert/impl/from_float_to_value.hh
index aa880d8..0a275ed 100644
--- a/milena/mln/convert/impl/from_float_to_value.hh
+++ b/milena/mln/convert/impl/from_float_to_value.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2008, 2009, 2010, 2011 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2008, 2009, 2010, 2011, 2012 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -45,123 +45,116 @@
namespace mln
{
+ /// \internal Conversion: float-> Value
+ template <typename V>
+ void from_to_(const float& from, Value<V>& to);
+
+ /// \internal Conversion: float-> unsigned
+ void from_to_(const float& from, unsigned& to);
+
+ /// \internal Conversion: float-> int
+ void from_to_(const float& from, int& to);
+
+ /// \internal Conversion: float-> short
+ void from_to_(const float& from, short& to);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
namespace convert
{
- /// Conversion of a float \p from towards a value \p to.
+ namespace impl
+ {
+
+ // Case 1:
+
template <typename V>
+ inline
void
- from_to(const float& from, Value<V>& to);
-
+ from_float_to_value(const float& from,
+ mln::value::Integer<V>& to)
+ {
+ exact(to) = math::round<V>()(from);
+ }
-# ifndef MLN_INCLUDE_ONLY
+ // Case 2:
- namespace impl
+ template <typename V>
+ inline
+ void
+ from_float_to_value(const float& from,
+ mln::value::Floating<V>& to)
{
+ exact(to) = from;
+ }
- // Case 1:
- template <typename V>
- inline
- void
- from_float_to_value(const float& from,
- mln::value::Integer<V>& to)
- {
- exact(to) = math::round<V>()(from);
- }
+ // Default: no conversion defined.
- // Case 2:
+ template <typename V>
+ inline
+ void
+ from_float_to_value(const float& from,
+ Value<V>& to)
+ {
+ (void) from;
+ (void) to;
+ mlc_abort(V)::check();
+ }
- template <typename V>
- inline
- void
- from_float_to_value(const float& from,
- mln::value::Floating<V>& to)
- {
- exact(to) = from;
- }
+ } // end of namespace mln::convert::impl
- // Default: no conversion defined.
+ namespace internal
+ {
- template <typename V>
- inline
- void
- from_float_to_value(const float& from,
- Value<V>& to)
- {
- (void) from;
- (void) to;
- mlc_abort(V)::check();
- }
+ template <typename V>
+ inline
+ void
+ from_float_to_value_dispatch(const float& from, Value<V>& to)
+ {
+ impl::from_float_to_value(from, exact(to));
+ }
- } // end of namespace mln::convert::impl
+ } // end of namespace mln::convert::internal
+ } // end of namespace mln::convert
- namespace internal
- {
- template <typename V>
- inline
- void
- from_float_to_value_dispatch(const float& from, Value<V>& to)
- {
- impl::from_float_to_value(from, exact(to));
- }
+ template <typename V>
+ inline
+ void
+ from_to_(const float& from, Value<V>& to)
+ {
+ convert::internal::from_float_to_value_dispatch(from, to);
+ }
- } // end of namespace mln::convert::internal
+ inline
+ void
+ from_to_(const float& from, unsigned& to)
+ {
+ mln_precondition(from >= 0);
+ to = math::round<unsigned>()(from);
+ }
+ inline
+ void
+ from_to_(const float& from, int& to)
+ {
+ to = math::round<int>()(from);
+ }
- namespace over_load
- {
+ inline
+ void
+ from_to_(const float& from, short& to)
+ {
+ to = math::round<short>()(from);
+ }
- // Facades.
-
-
- // float-> Value
- template <typename V>
- inline
- void
- from_to_(const float& from, Value<V>& to)
- {
- internal::from_float_to_value_dispatch(from, to);
- }
-
- // float-> unsigned
- inline
- void
- from_to_(const float& from,
- unsigned& to)
- {
- mln_precondition(from >= 0);
- to = math::round<unsigned>()(from);
- }
-
- // float-> int
- inline
- void
- from_to_(const float& from,
- int& to)
- {
- to = math::round<int>()(from);
- }
-
- // float-> short
- inline
- void
- from_to_(const float& from,
- short& to)
- {
- to = math::round<short>()(from);
- }
-
-
- } // end of namespace mln::convert::over_load
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace mln::convert
-
} // end of namespace mln
diff --git a/milena/mln/convert/impl/from_image_to_site_set.hh b/milena/mln/convert/impl/from_image_to_site_set.hh
index 65873b6..e78538b 100644
--- a/milena/mln/convert/impl/from_image_to_site_set.hh
+++ b/milena/mln/convert/impl/from_image_to_site_set.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008, 2009, 2011 EPITA Research and Development
+// Copyright (C) 2008, 2009, 2011, 2012 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -94,8 +94,8 @@ namespace mln
p.next();
}
while (p.is_valid() && input(p) == true &&
- // p follows q in a run, i.e., "p == q + right":
- cut_(p.to_site()) == cut_(q) && p.last_coord() == q.last_coord() + 1);
+ // p follows q in a run, i.e., "p == q + right":
+ cut_(p.to_site()) == cut_(q) && p.last_coord() == q.last_coord() + 1);
s.insert(p_run<P>(start, q));
}
}
@@ -123,7 +123,7 @@ namespace mln
p.next();
}
while (p.is_valid() && input(p) == v &&
- cut_(p.to_site()) == cut_(q) && p.last_coord() == q.last_coord() + 1);
+ cut_(p.to_site()) == cut_(q) && p.last_coord() == q.last_coord() + 1);
s.insert(v, p_run<P>(start, q));
}
}
diff --git a/milena/mln/convert/impl/from_int_to_value.hh b/milena/mln/convert/impl/from_int_to_value.hh
index c22dfb1..4074ed0 100644
--- a/milena/mln/convert/impl/from_int_to_value.hh
+++ b/milena/mln/convert/impl/from_int_to_value.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008, 2009, 2010 EPITA Research and Development
+// Copyright (C) 2008, 2009, 2010, 2012 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -44,79 +44,72 @@
namespace mln
{
- namespace convert
- {
-
- /// Conversion of a int \p from towards a value \p to.
- template <typename V>
- void
- from_to(const int& from, Value<V>& to);
+ /// \internal Conversion: int-> Value
+ template <typename V>
+ void from_to_(const int& from, Value<V>& to);
# ifndef MLN_INCLUDE_ONLY
- namespace impl
- {
+ namespace convert
+ {
- // Case 1:
+ namespace impl
+ {
- template <typename V>
- inline
- void
- from_int_to_value(const int& from,
- mln::value::Integer<V>& to)
- {
- exact(to) = from;
- }
+ // Case 1:
- // Default: no conversion defined.
+ template <typename V>
+ inline
+ void
+ from_int_to_value(const int& from,
+ mln::value::Integer<V>& to)
+ {
+ exact(to) = from;
+ }
- template <typename V>
- inline
- void
- from_int_to_value(const int& from,
- Value<V>& to)
- {
- (void) from;
- (void) to;
- mlc_abort(V)::check();
- }
+ // Default: no conversion defined.
- } // end of namespace mln::convert::impl
+ template <typename V>
+ inline
+ void
+ from_int_to_value(const int& from,
+ Value<V>& to)
+ {
+ (void) from;
+ (void) to;
+ mlc_abort(V)::check();
+ }
+ } // end of namespace mln::convert::impl
- namespace internal
- {
+ namespace internal
+ {
- template <typename V>
- inline
- void
- from_int_to_value_dispatch(const int& from, Value<V>& to)
- {
- impl::from_int_to_value(from, exact(to));
- }
+ template <typename V>
+ inline
+ void
+ from_int_to_value_dispatch(const int& from, Value<V>& to)
+ {
+ impl::from_int_to_value(from, exact(to));
+ }
- } // end of namespace mln::convert::internal
+ } // end of namespace mln::convert::internal
+ } // end of namespace mln::convert
- namespace over_load
- {
- // Facades.
- // int-> Value
- template <typename V>
- void
- from_to_(const int& from, Value<V>& to)
- {
- internal::from_int_to_value_dispatch(from, to);
- }
+ // Facades.
- } // end of namespace mln::convert::over_load
+ template <typename V>
+ void
+ from_to_(const int& from, Value<V>& to)
+ {
+ convert::internal::from_int_to_value_dispatch(from, to);
+ }
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace mln::convert
-
} // end of namespace mln
diff --git a/milena/mln/convert/impl/from_unsigned_to_value.hh b/milena/mln/convert/impl/from_unsigned_to_value.hh
index 783b5e9..383f989 100644
--- a/milena/mln/convert/impl/from_unsigned_to_value.hh
+++ b/milena/mln/convert/impl/from_unsigned_to_value.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2009, 2010, 2011 EPITA Research and Development
+// Copyright (C) 2009, 2010, 2011, 2012 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -45,102 +45,92 @@
namespace mln
{
- namespace convert
- {
- /// Conversion of an unsigned \p from towards a value \p to.
- template <typename V>
- void
- from_to(const unsigned& from, Value<V>& to);
+ /// \internal Conversion: unsigned-> Value
+ template <typename V>
+ void from_to_(const unsigned& from, Value<V>& to);
+
+ /// \internal Conversion: unsigned -> bool
+ void from_to_(const unsigned& from, bool& to);
+
- /// Conversion of an unsigned \p from towards a bool \p to.
- inline
- void
- from_to_(const unsigned& from, bool& to);
# ifndef MLN_INCLUDE_ONLY
- namespace impl
+ namespace convert
+ {
+
+ namespace impl
+ {
+
+ // Case 1:
+
+ template <typename V>
+ inline
+ void
+ from_unsigned_to_value(const unsigned& from,
+ mln::value::Integer<V>& to)
{
+ exact(to) = from;
+ }
+
+ template <unsigned n>
+ inline
+ void
+ from_unsigned_to_value(const unsigned& from,
+ mln::value::label<n>& to)
+ {
+ exact(to) = from;
+ }
+
+ // Default: no conversion defined.
- // Case 1:
-
- template <typename V>
- inline
- void
- from_unsigned_to_value(const unsigned& from,
- mln::value::Integer<V>& to)
- {
- exact(to) = from;
- }
-
- template <unsigned n>
- inline
- void
- from_unsigned_to_value(const unsigned& from,
- mln::value::label<n>& to)
- {
- exact(to) = from;
- }
-
- // Default: no conversion defined.
-
- template <typename V>
- inline
- void
- from_unsigned_to_value(const unsigned&,
- Value<V>&)
- {
- mlc_abort(V)::check();
- }
-
- } // end of namespace mln::convert::impl
-
-
- namespace internal
+ template <typename V>
+ inline
+ void
+ from_unsigned_to_value(const unsigned&,
+ Value<V>&)
{
+ mlc_abort(V)::check();
+ }
- template <typename V>
- inline
- void
- from_unsigned_to_value_dispatch(const unsigned& from, Value<V>& to)
- {
- impl::from_unsigned_to_value(from, exact(to));
- }
+ } // end of namespace mln::convert::impl
- } // end of namespace mln::convert::unsignedernal
+ namespace internal
+ {
- namespace over_load
+ template <typename V>
+ inline
+ void
+ from_unsigned_to_value_dispatch(const unsigned& from, Value<V>& to)
{
+ impl::from_unsigned_to_value(from, exact(to));
+ }
- // Facades.
- // unsigned-> Value
- template <typename V>
- void
- from_to_(const unsigned& from, Value<V>& to)
- {
- internal::from_unsigned_to_value_dispatch(from, to);
- }
+ } // end of namespace mln::convert::unsignedernal
+
+ } // end of namespace mln::convert
- // Facades.
- // unsigned-> bool
- inline
- void
- from_to_(const unsigned& from, bool& to)
- {
- to = (from != 0u);
- }
+ template <typename V>
+ void
+ from_to_(const unsigned& from, Value<V>& to)
+ {
+ convert::internal::from_unsigned_to_value_dispatch(from, to);
+ }
- } // end of namespace mln::convert::over_load
+ inline
+ void
+ from_to_(const unsigned& from, bool& to)
+ {
+ to = (from != 0u);
+ }
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace mln::convert
-
} // end of namespace mln
diff --git a/milena/mln/convert/impl/from_value_to_value.hh b/milena/mln/convert/impl/from_value_to_value.hh
index 347338b..fea91a3 100644
--- a/milena/mln/convert/impl/from_value_to_value.hh
+++ b/milena/mln/convert/impl/from_value_to_value.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -41,8 +42,6 @@
# include <mln/core/site_set/p_run.hh>
# include <mln/metal/converts_to.hh>
-# include <mln/convert/from_to.hxx>
-
namespace mln
{
@@ -93,7 +92,7 @@ namespace mln
{
// No concept based conversion. Trying to find more specific
// conversion with other from_to overloads.
- convert::over_load::from_to_(exact(from), exact(to));
+ from_to_(exact(from), exact(to));
}
diff --git a/milena/mln/convert/to.hh b/milena/mln/convert/to.hh
index f88f621..5c46416 100644
--- a/milena/mln/convert/to.hh
+++ b/milena/mln/convert/to.hh
@@ -36,7 +36,6 @@
# include <mln/metal/equal.hh>
# include <mln/trace/all.hh>
# include <mln/convert/from_to.hh>
-# include <mln/convert/from_to.hxx>
namespace mln
diff --git a/milena/mln/core/alias/neighb2d.hh b/milena/mln/core/alias/neighb2d.hh
index ee86509..63fbc55 100644
--- a/milena/mln/core/alias/neighb2d.hh
+++ b/milena/mln/core/alias/neighb2d.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -123,22 +124,13 @@ namespace mln
neighb< win::multiple<window2d, mln::fun::p2b::chess> > c6_2d();
+ /// \internal Conversion: bool[] -> neighb2d
+ template <unsigned S>
+ void from_to_(const bool (&values)[S], neighb2d& nbh);
- namespace convert
- {
-
- namespace over_load
- {
-
- template <unsigned S>
- void from_to_(const bool (&values)[S], neighb2d& nbh);
-
- template <unsigned R, unsigned C>
- void from_to_(bool const (&values)[R][C], neighb2d& nbh);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ /// \internal Conversion: bool[][] -> neighb2d
+ template <unsigned R, unsigned C>
+ void from_to_(bool const (&values)[R][C], neighb2d& nbh);
@@ -208,48 +200,39 @@ namespace mln
bool vert[] = { 1, 1, 0,
1, 0, 1,
0, 1, 1 };
-
+
bool hori[] = { 0, 1, 1,
1, 0, 1,
1, 1, 0 };
-
+
return make::double_neighb2d(fun::p2b::chess(),
vert,
hori);
}
- namespace convert
+ template <unsigned S>
+ void
+ from_to_(const bool (&values)[S], neighb2d& nbh)
{
+ enum { h = mlc_sqrt_int(S) / 2 };
+ mlc_bool((2 * h + 1) * (2 * h + 1) == S)::check();
+ window2d& win = nbh.hook_win_();
+ convert::from_to(values, win);
+ mln_postcondition(win.is_neighbable_());
+ }
- namespace over_load
- {
-
- template <unsigned S>
- void
- from_to_(const bool (&values)[S], neighb2d& nbh)
- {
- enum { h = mlc_sqrt_int(S) / 2 };
- mlc_bool((2 * h + 1) * (2 * h + 1) == S)::check();
- window2d& win = nbh.hook_win_();
- convert::from_to(values, win);
- mln_postcondition(win.is_neighbable_());
- }
-
- template <unsigned R, unsigned C>
- void
- from_to_(bool const (&values)[R][C], neighb2d& nbh)
- {
- mlc_bool(R % 2 == 1)::check();
- mlc_bool(C % 2 == 1)::check();
- window2d& win = nbh.hook_win_();
- convert::from_to(values, win);
- mln_postcondition(win.is_neighbable_());
- }
-
- } // end of namespace mln::convert::over_load
+ template <unsigned R, unsigned C>
+ void
+ from_to_(bool const (&values)[R][C], neighb2d& nbh)
+ {
+ mlc_bool(R % 2 == 1)::check();
+ mlc_bool(C % 2 == 1)::check();
+ window2d& win = nbh.hook_win_();
+ convert::from_to(values, win);
+ mln_postcondition(win.is_neighbable_());
+ }
- } // end of namespace mln::convert
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/core/alias/neighb3d.hh b/milena/mln/core/alias/neighb3d.hh
index a5dead7..cb2d809 100644
--- a/milena/mln/core/alias/neighb3d.hh
+++ b/milena/mln/core/alias/neighb3d.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -203,21 +204,9 @@ namespace mln
const neighb3d& c26();
-
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <unsigned S>
- void from_to_(const bool (&values)[S], neighb3d& nbh);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
+ /// \internal Conversion: bool[] -> neighb3d
+ template <unsigned S>
+ void from_to_(const bool (&values)[S], neighb3d& nbh);
# ifndef MLN_INCLUDE_ONLY
@@ -325,29 +314,19 @@ namespace mln
}
- namespace convert
+ template <unsigned S>
+ void
+ from_to_(const bool (&values)[S], neighb3d& nbh)
{
-
- namespace over_load
- {
-
- template <unsigned S>
- void
- from_to_(const bool (&values)[S], neighb3d& nbh)
- {
# ifndef NDEBUG
- const int h = unsigned(std::pow(float(S), float(1. / 3.))) / 2;
- mln_precondition((2 * h + 1) * (2 * h + 1) * (2 * h + 1) == S);
+ const int h = unsigned(std::pow(float(S), float(1. / 3.))) / 2;
+ mln_precondition((2 * h + 1) * (2 * h + 1) * (2 * h + 1) == S);
# endif // ! NDEBUG
- window3d win;
- from_to_(values, win);
- mln_precondition(win.is_neighbable_());
- nbh.change_window(win);
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ window3d win;
+ from_to_(values, win);
+ mln_precondition(win.is_neighbable_());
+ nbh.change_window(win);
+ }
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/core/alias/point1d.hh b/milena/mln/core/alias/point1d.hh
index 5cd9803..f3cde66 100644
--- a/milena/mln/core/alias/point1d.hh
+++ b/milena/mln/core/alias/point1d.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -31,6 +32,8 @@
/// Definition of the mln::point1d and mln::point1df aliases and of
/// their construction routines.
+# include <mln/core/def/coord.hh>
+# include <mln/core/def/coordf.hh>
# include <mln/core/point.hh>
// For site_const_impl and site_mutable_impl.
# include <mln/core/concept/site_proxy.hh>
diff --git a/milena/mln/core/alias/point2d.hh b/milena/mln/core/alias/point2d.hh
index dd79faa..5a7ae65 100644
--- a/milena/mln/core/alias/point2d.hh
+++ b/milena/mln/core/alias/point2d.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -31,6 +32,8 @@
/// Definition of the mln::point2d and mln::point2df aliases and of
/// their construction routines.
+# include <mln/core/def/coord.hh>
+# include <mln/core/def/coordf.hh>
# include <mln/core/point.hh>
// For site_const_impl and site_mutable_impl.
# include <mln/core/concept/site_proxy.hh>
diff --git a/milena/mln/core/alias/point3d.hh b/milena/mln/core/alias/point3d.hh
index 6aaede0..bfc6bee 100644
--- a/milena/mln/core/alias/point3d.hh
+++ b/milena/mln/core/alias/point3d.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -31,6 +32,8 @@
/// Definition of the mln::point3d and mln::point3df aliases and of
/// their construction routines.
+# include <mln/core/def/coord.hh>
+# include <mln/core/def/coordf.hh>
# include <mln/core/point.hh>
// For site_const_impl and site_mutable_impl:
# include <mln/core/concept/site_proxy.hh>
diff --git a/milena/mln/core/alias/window1d.hh b/milena/mln/core/alias/window1d.hh
index 6564e43..dd2d4fc 100644
--- a/milena/mln/core/alias/window1d.hh
+++ b/milena/mln/core/alias/window1d.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -47,45 +48,25 @@ namespace mln
typedef window<mln::dpoint1d> window1d;
- namespace convert
- {
-
- namespace over_load
- {
-
- template <unsigned M>
- void from_to_(const bool (&values)[M], window1d& win);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
+ /// \internal Conversion: bool[] -> window1d
+ template <unsigned M>
+ void from_to_(const bool (&values)[M], window1d& win);
# ifndef MLN_INCLUDE_ONLY
- namespace convert
+ template <unsigned M>
+ void
+ from_to_(bool const (&values)[M], window1d& win)
{
-
- namespace over_load
- {
-
- template <unsigned M>
- void
- from_to_(bool const (&values)[M], window1d& win)
- {
- mlc_bool(M % 2 == 1)::check();
- win.clear();
- const int h = int(M) / 2;
- unsigned i = 0;
- for (int ind = - h; ind <= h; ++ind)
- if (values[i++])
- win.insert(ind);
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ mlc_bool(M % 2 == 1)::check();
+ win.clear();
+ const int h = int(M) / 2;
+ unsigned i = 0;
+ for (int ind = - h; ind <= h; ++ind)
+ if (values[i++])
+ win.insert(ind);
+ }
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/core/alias/window2d.hh b/milena/mln/core/alias/window2d.hh
index 5b8fe31..aa56837 100644
--- a/milena/mln/core/alias/window2d.hh
+++ b/milena/mln/core/alias/window2d.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008, 2009, 2010 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2010, 2012 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -35,7 +35,6 @@
# include <mln/core/window.hh>
# include <mln/core/alias/dpoint2d.hh>
# include <mln/metal/math/sqrt.hh>
-# include <mln/convert/from_to.hxx>
namespace mln
@@ -81,22 +80,13 @@ namespace mln
const window2d& win_c8p();
- namespace convert
- {
-
- namespace over_load
- {
-
- template <unsigned S>
- void from_to_(const bool (&values)[S], window2d& win);
-
- template <unsigned R, unsigned C>
- void from_to_(const bool (&values)[R][C], window2d& win);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ /// \internal Conversion: bool[] -> window2d
+ template <unsigned S>
+ void from_to_(const bool (&values)[S], window2d& win);
+ /// \internal Conversion: bool[][] -> window2d
+ template <unsigned R, unsigned C>
+ void from_to_(const bool (&values)[R][C], window2d& win);
# ifndef MLN_INCLUDE_ONLY
@@ -138,50 +128,40 @@ namespace mln
}
- namespace convert
+ template <unsigned S>
+ void
+ from_to_(const bool (&values)[S], window2d& win)
{
+ enum { H = mlc_sqrt_int(S) / 2 };
+ mlc_bool((2 * H + 1) * (2 * H + 1) == S)::check();
+ win.clear();
+ unsigned i = 0;
+ const def::coord
+ h = static_cast<def::coord>(H),
+ _h = static_cast<def::coord>(-h);
+ for (def::coord row = _h; row <= h; ++row)
+ for (def::coord col = _h; col <= h; ++col)
+ if (values[i++])
+ win.insert(row, col);
+ }
- namespace over_load
- {
-
- template <unsigned S>
- void
- from_to_(const bool (&values)[S], window2d& win)
- {
- enum { H = mlc_sqrt_int(S) / 2 };
- mlc_bool((2 * H + 1) * (2 * H + 1) == S)::check();
- win.clear();
- unsigned i = 0;
- const def::coord
- h = static_cast<def::coord>(H),
- _h = static_cast<def::coord>(-h);
- for (def::coord row = _h; row <= h; ++row)
- for (def::coord col = _h; col <= h; ++col)
- if (values[i++])
- win.insert(row, col);
- }
-
- template <unsigned R, unsigned C>
- void
- from_to_(const bool (&values)[R][C], window2d& win)
- {
- mlc_bool(R % 2 == 1)::check();
- mlc_bool(C % 2 == 1)::check();
- win.clear();
- const def::coord
- drow = static_cast<def::coord>(R / 2),
- _drow = static_cast<def::coord>(- drow),
- dcol = static_cast<def::coord>(C / 2),
- _dcol = static_cast<def::coord>(- dcol);
- for (def::coord row = _drow; row <= drow; ++row)
- for (def::coord col = _dcol; col <= dcol; ++col)
- if (values[row + drow][col + dcol])
- win.insert(row, col);
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ template <unsigned R, unsigned C>
+ void
+ from_to_(const bool (&values)[R][C], window2d& win)
+ {
+ mlc_bool(R % 2 == 1)::check();
+ mlc_bool(C % 2 == 1)::check();
+ win.clear();
+ const def::coord
+ drow = static_cast<def::coord>(R / 2),
+ _drow = static_cast<def::coord>(- drow),
+ dcol = static_cast<def::coord>(C / 2),
+ _dcol = static_cast<def::coord>(- dcol);
+ for (def::coord row = _drow; row <= drow; ++row)
+ for (def::coord col = _dcol; col <= dcol; ++col)
+ if (values[row + drow][col + dcol])
+ win.insert(row, col);
+ }
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/core/alias/window3d.hh b/milena/mln/core/alias/window3d.hh
index 108ea4e..6a29c06 100644
--- a/milena/mln/core/alias/window3d.hh
+++ b/milena/mln/core/alias/window3d.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -97,19 +98,9 @@ namespace mln
const window3d& win_c8p_3d();
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <unsigned M>
- void from_to_(bool const (&values)[M], window3d& win);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ /// \internal Conversion: bool[] -> window3d
+ template <unsigned M>
+ void from_to_(bool const (&values)[M], window3d& win);
@@ -151,30 +142,23 @@ namespace mln
return it;
}
- namespace convert
- {
- namespace over_load
- {
+ // Conversion
- template <unsigned M>
- void
- from_to_(bool const (&values)[M], window3d& win)
- {
- const int h = unsigned(std::pow(float(M), float(1. / 3.))) / 2;
- mln_precondition((2 * h + 1) * (2 * h + 1) * (2 * h + 1) == M);
- win.clear();
- unsigned i = 0;
- for (int sli = - h; sli <= h; ++sli)
- for (int row = - h; row <= h; ++row)
- for (int col = - h; col <= h; ++col)
- if (values[i++])
- win.insert(sli, row, col);
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ template <unsigned M>
+ void
+ from_to_(bool const (&values)[M], window3d& win)
+ {
+ const int h = unsigned(std::pow(float(M), float(1. / 3.))) / 2;
+ mln_precondition((2 * h + 1) * (2 * h + 1) * (2 * h + 1) == M);
+ win.clear();
+ unsigned i = 0;
+ for (int sli = - h; sli <= h; ++sli)
+ for (int row = - h; row <= h; ++row)
+ for (int col = - h; col <= h; ++col)
+ if (values[i++])
+ win.insert(sli, row, col);
+ }
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/core/concept/accumulator.hh b/milena/mln/core/concept/accumulator.hh
index a28664e..968ec3a 100644
--- a/milena/mln/core/concept/accumulator.hh
+++ b/milena/mln/core/concept/accumulator.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008, 2009, 2011 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2011, 2012 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -40,25 +40,6 @@
namespace mln
{
- // Forward declaration.
- template <typename E> struct Accumulator;
-
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename A>
- void
- from_to_(const Accumulator<A>& from, mln_result(A)& to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
// Accumulator category flag type.
template <>
struct Accumulator<void>
@@ -118,39 +99,19 @@ namespace mln
template <typename T>
void take_n_times_(unsigned n, const T& t);
-
+
protected:
Accumulator();
};
-# ifndef MLN_INCLUDE_ONLY
-
-
- // convert::from_to_
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename A>
- void
- from_to_(const Accumulator<A>& from_, mln_result(A)& to)
- {
- const A& from = exact(from_);
- if (from.is_valid())
- to = from.to_result();
- else
- to = mln_result(A)();
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ /// \internal Conversion: Accumulator -> mln_result(A)
+ template <typename A>
+ void
+ from_to_(const Accumulator<A>& from, mln_result(A)& to);
+# ifndef MLN_INCLUDE_ONLY
// Accumulator<E>
@@ -235,6 +196,21 @@ namespace mln
exact(this)->take(t);
}
+
+ // Conversions
+
+ template <typename A>
+ void
+ from_to_(const Accumulator<A>& from_, mln_result(A)& to)
+ {
+ const A& from = exact(from_);
+ if (from.is_valid())
+ to = from.to_result();
+ else
+ to = mln_result(A)();
+ }
+
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
diff --git a/milena/mln/core/concept/gdpoint.hh b/milena/mln/core/concept/gdpoint.hh
index 722db89..2a7adf9 100644
--- a/milena/mln/core/concept/gdpoint.hh
+++ b/milena/mln/core/concept/gdpoint.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008, 2009, 2011 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2011, 2012 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -134,28 +134,10 @@ namespace mln
operator*(const Gdpoint<D>& lhs, const value::Scalar<S>& rhs);
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename D>
- void
- from_to_(const Gdpoint<D>& from, mln_site(D)& to);
-
-// template <typename D, unsigned n, typename T>
-// void
-// from_to_(const Gdpoint<D>& from, algebra::vec<n,T>& to);
-
-// template <unsigned n, typename T, typename D>
-// void
-// from_to_(const algebra::vec<n,T>& from, Gdpoint<D>& to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ /// \internal Conversion: gdpoint -> mln_site
+ template <typename D>
+ void
+ from_to_(const Gdpoint<D>& from, mln_site(D)& to);
# ifndef MLN_INCLUDE_ONLY
@@ -220,26 +202,18 @@ namespace mln
}
- namespace convert
- {
+ // Conversions
- namespace over_load
- {
-
- template <typename D>
- inline
- void
- from_to_(const Gdpoint<D>& dp_, mln_site(D)& p)
- {
- enum { n = D::dim };
- const D& dp = exact(dp_);
- for (unsigned i = 0; i < n; ++i)
- p[i] = dp[i];
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ template <typename D>
+ inline
+ void
+ from_to_(const Gdpoint<D>& dp_, mln_site(D)& p)
+ {
+ enum { n = D::dim };
+ const D& dp = exact(dp_);
+ for (unsigned i = 0; i < n; ++i)
+ p[i] = dp[i];
+ }
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/core/concept/gpoint.hh b/milena/mln/core/concept/gpoint.hh
index 410b36a..d51b2f4 100644
--- a/milena/mln/core/concept/gpoint.hh
+++ b/milena/mln/core/concept/gpoint.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008, 2009, 2011 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2011, 2012 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -128,30 +128,6 @@ namespace mln
};
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename P>
- void
- from_to_(const Gpoint<P>& from, mln_delta(P)& to);
-
- template <typename P, unsigned n, typename T>
- void
- from_to_(const Gpoint<P>& from, algebra::vec<n,T>& to);
-
- template <unsigned n, typename T, typename P>
- void
- from_to_(const algebra::vec<n,T>& from, Gpoint<P>& to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
-
/// Equality comparison between a couple of grid point \p lhs
/// and \p rhs.
/*!
@@ -289,6 +265,17 @@ namespace mln
// FIXME : add operators and traits?
+ /// \internal Conversion: gpoint -> mln_delta
+ template <typename P>
+ void
+ from_to_(const Gpoint<P>& from, mln_delta(P)& to);
+
+ /// \internal Conversion: gpoint -> algebra::vec
+ template <typename P, unsigned n, typename T>
+ void
+ from_to_(const Gpoint<P>& from, algebra::vec<n,T>& to);
+
+
# ifndef MLN_INCLUDE_ONLY
@@ -306,59 +293,6 @@ namespace mln
(void) m;
}
-
- // convert::from_to_
-
- namespace convert
- {
-
- namespace over_load
- {
-
- // Gpoint -> delta
- template <typename P>
- inline
- void
- from_to_(const Gpoint<P>& p_, mln_delta(P)& dp)
- {
- // Instead of "dp.to_vec() = exact(p).to_vec();" that
- // does not compile (cause to_vec returns const), we
- // have:
- enum { n = P::dim };
- const P& p = exact(p_);
- for (unsigned i = 0; i < n; ++i)
- dp[i] = p[i];
- }
-
- // Gpoint -> algebra::vec.
- template <typename P, unsigned n, typename T>
- inline
- void
- from_to_(const Gpoint<P>& from_, algebra::vec<n,T>& to)
- {
- mlc_bool(n == P::dim)::check();
- const P& from = exact(from_);
- for (unsigned i = 0; i < n; ++i)
- to[i] = static_cast< T >(from[i]); // FIXME: cast -> best effort...
- }
-
- // algebra::vec -> Gpoint.
- template <unsigned n, typename T, typename P>
- inline
- void
- from_to_(const algebra::vec<n,T>& from, Gpoint<P>& to_)
- {
- mlc_bool(P::dim == n)::check();
- P& to = exact(to_);
- for (unsigned i = 0; i < n; ++i)
- to[i] = static_cast< typename P::coord >(from[i]); // FIXME: cast -> best effort...
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
// Operators.
template <typename L, typename R>
@@ -454,6 +388,36 @@ namespace mln
return tmp;
}
+
+
+ // Conversions
+
+ template <typename P>
+ inline
+ void
+ from_to_(const Gpoint<P>& p_, mln_delta(P)& dp)
+ {
+ // Instead of "dp.to_vec() = exact(p).to_vec();" that
+ // does not compile (cause to_vec returns const), we
+ // have:
+ enum { n = P::dim };
+ const P& p = exact(p_);
+ for (unsigned i = 0; i < n; ++i)
+ dp[i] = p[i];
+ }
+
+ template <typename P, unsigned n, typename T>
+ inline
+ void
+ from_to_(const Gpoint<P>& from_, algebra::vec<n,T>& to)
+ {
+ mlc_bool(n == P::dim)::check();
+ const P& from = exact(from_);
+ for (unsigned i = 0; i < n; ++i)
+ to[i] = static_cast< T >(from[i]); // FIXME: cast -> best effort...
+ }
+
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
diff --git a/milena/mln/core/concept/image.hh b/milena/mln/core/concept/image.hh
index 4c70768..a79cd37 100644
--- a/milena/mln/core/concept/image.hh
+++ b/milena/mln/core/concept/image.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008, 2009, 2011 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2011, 2012 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -55,6 +55,7 @@ namespace mln
// Forward declarations.
template <typename E> struct Image;
template <typename E> struct Literal;
+ template <typename D, typename W> struct w_window;
// Image category flag type.
@@ -121,20 +122,15 @@ namespace mln
};
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename V, unsigned S, typename I>
- void
- from_to_(const V (&values)[S], Image<I>& to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ /// \internal Conversion: image -> w_window
+ template <typename I, typename D, typename W>
+ void
+ from_to_(const Image<I>& from, w_window<D,W>& to);
+ /// \internal Conversion: values[] -> image
+ template <typename V, unsigned S, typename I>
+ void
+ from_to_(const V (&values)[S], Image<I>& to);
# ifndef MLN_INCLUDE_ONLY
@@ -269,43 +265,48 @@ namespace mln
}
- namespace convert
+ template <typename I, typename D, typename W>
+ void
+ from_to_(const Image<I>& from_, w_window<D,W>& to)
{
+ mlc_converts_to(mln_deduce(I, psite, delta), D)::check();
+ mlc_converts_to(mln_value(I), W)::check();
+ const I& ima = exact(from_);
+ to.clear();
+ mln_value(I) zero = literal::zero;
+ mln_piter(I) p(ima.domain());
+ for_all(p)
+ if (ima(p) != zero)
+ to.insert(ima(p), convert::to<D>(p));
+ }
- namespace over_load
- {
-
- template <typename V, unsigned S, typename I>
- void
- from_to_(const V (&values)[S], Image<I>& to_)
- {
- mlc_bool(S != 0)::check();
- mlc_converts_to(V, mln_value(I))::check();
- typedef mln_site(I) P;
- enum { d = P::dim,
- s = mlc_root(d, S)::value };
- metal::bool_<(mlc_pow_int(s, d) == S)>::check();
-
- I& to = exact(to_);
- mln_precondition(! to.is_valid());
-
- box<P> b(all_to(0), all_to(s - 1));
- to.init_(b);
- mln_fwd_piter(box<P>) p(b);
- unsigned i = 0;
- for_all(p)
- to(p) = values[i++];
- }
-
- } // end of namespace mln::convert::over_load
+ template <typename V, unsigned S, typename I>
+ void
+ from_to_(const V (&values)[S], Image<I>& to_)
+ {
+ mlc_bool(S != 0)::check();
+ mlc_converts_to(V, mln_value(I))::check();
+ typedef mln_site(I) P;
+ enum { d = P::dim,
+ s = mlc_root(d, S)::value };
+ metal::bool_<(mlc_pow_int(s, d) == S)>::check();
+
+ I& to = exact(to_);
+ mln_precondition(! to.is_valid());
+
+ box<P> b(all_to(0), all_to(s - 1));
+ to.init_(b);
+ mln_fwd_piter(box<P>) p(b);
+ unsigned i = 0;
+ for_all(p)
+ to(p) = values[i++];
+ }
- } // end of namespace mln::convert
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
-
# include <mln/core/routine/initialize.hh>
diff --git a/milena/mln/core/concept/proxy.hh b/milena/mln/core/concept/proxy.hh
index f22f342..8c4d2e9 100644
--- a/milena/mln/core/concept/proxy.hh
+++ b/milena/mln/core/concept/proxy.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008, 2009, 2011 EPITA Research and Development
+// Copyright (C) 2008, 2009, 2011, 2012 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -144,16 +144,6 @@ namespace mln
template <typename E> struct Literal;
- namespace convert
- {
-
- template <typename F, typename T>
- void from_to(const F& from, T& to);
-
- }
-
-
-
namespace trait
{
@@ -245,21 +235,10 @@ namespace mln
};
- // convert::from_to_
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename P, typename T>
- void
- from_to_(const Proxy<P>& from, T& to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ /// \internal Conversion: proxy -> T
+ template <typename P, typename T>
+ void
+ from_to_(const Proxy<P>& from, T& to);
@@ -337,24 +316,14 @@ namespace mln
- // convert::from_to_
+ // Conversion
- namespace convert
+ template <typename P, typename T>
+ void
+ from_to_(const Proxy<P>& from, T& to)
{
-
- namespace over_load
- {
-
- template <typename P, typename T>
- void
- from_to_(const Proxy<P>& from, T& to)
- {
- convert::from_to(exact(from).unproxy_(), to);
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ convert::from_to(exact(from).unproxy_(), to);
+ }
// unproxy_rec
diff --git a/milena/mln/core/concept/site_set.hh b/milena/mln/core/concept/site_set.hh
index bbf217c..2e25f93 100644
--- a/milena/mln/core/concept/site_set.hh
+++ b/milena/mln/core/concept/site_set.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008, 2009, 2011 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2011, 2012 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -87,26 +87,26 @@ namespace mln
};
+ /// \internal Conversion: site_set -> std::set
+ template <typename S, typename P, typename C_>
+ void
+ from_to_(const Site_Set<S>& from, std::set<P,C_>& to);
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename S, typename P, typename C_>
- void
- from_to_(const Site_Set<S>& from, std::set<P,C_>& to);
+} // end of namespace mln
- template <typename P, typename C_, typename S>
- void
- from_to_(const std::set<P,C_>& from, Site_Set<S>& to);
+namespace std
+{
- } // end of namespace mln::convert::over_load
+ /// \internal Conversion: std::set -> site_set
+ template <typename P, typename C_, typename S>
+ void
+ from_to_(const set<P,C_>& from, mln::Site_Set<S>& to);
- } // end of namespace mln::convert
+} // end of namespace std
+namespace mln
+{
namespace trait
{
@@ -125,49 +125,12 @@ namespace mln
} // end of namespace mln::trait
-
+} // end of namespace mln
# ifndef MLN_INCLUDE_ONLY
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename S, typename P, typename C_>
- inline
- void
- from_to_(const Site_Set<S>& from_, std::set<P,C_>& to)
- {
- mlc_converts_to(mln_psite(S), P)::check();
- const S& from = exact(from_);
- to.clear();
- mln_piter(S) p(from);
- for_all(p)
- to.insert(p);
- }
-
-
- template <typename P, typename C_, typename S>
- inline
- void
- from_to_(const std::set<P,C_>& from, Site_Set<S>& to_)
- {
- mlc_converts_to(P, mln_i_element(S))::check();
- S& to = exact(to_);
- to.clear();
- for (typename std::set<P>::const_iterator i = from.begin();
- i != from.end();
- ++i)
- to.insert(*i);
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
+namespace mln
+{
namespace internal
{
@@ -293,10 +256,46 @@ namespace mln
internal::site_set_contents_check< mln_trait_site_set_contents(E), E >::run();
}
-# endif // ! MLN_INCLUDE_ONLY
+
+ // Conversion
+
+ template <typename S, typename P, typename C_>
+ inline
+ void
+ from_to_(const Site_Set<S>& from_, std::set<P,C_>& to)
+ {
+ mlc_converts_to(mln_psite(S), P)::check();
+ const S& from = exact(from_);
+ to.clear();
+ mln_piter(S) p(from);
+ for_all(p)
+ to.insert(p);
+ }
} // end of namespace mln
+namespace std
+{
+
+ template <typename P, typename C_, typename S>
+ inline
+ void
+ from_to_(const set<P,C_>& from, mln::Site_Set<S>& to_)
+ {
+ mlc_converts_to(P, mln_i_element(S))::check();
+ S& to = exact(to_);
+ to.clear();
+ for (typename set<P>::const_iterator i = from.begin();
+ i != from.end();
+ ++i)
+ to.insert(*i);
+ }
+
+} // end of namespace std
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
# include <mln/core/site_set/operators.hh>
# include <mln/core/routine/ops.hh>
diff --git a/milena/mln/core/concept/window.hh b/milena/mln/core/concept/window.hh
index 3b2eafb..9aa58bd 100644
--- a/milena/mln/core/concept/window.hh
+++ b/milena/mln/core/concept/window.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008, 2009, 2011 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2011, 2012 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -40,8 +40,7 @@
# include <mln/trait/windows.hh>
# include <mln/core/site_set/p_array.hh>
-# include <mln/core/internal/geom_bbox.hh> // For use in convert::from_to.
-# include <mln/convert/from_to.hxx>
+# include <mln/core/internal/geom_bbox.hh> // For use in from_to_.
# include <mln/util/array.hh>
@@ -112,34 +111,24 @@ namespace mln
std::ostream& operator<<(std::ostream& ostr, const Window<W>& win);
+ /// \internal Conversion: window -> image
+ template <typename W, typename I>
+ void
+ from_to_(const Window<W>& from, Image<I>& to);
+
+
// FIXME: Move as a method of Image?
template <typename I, typename W>
util::array<int>
offsets_wrt(const Image<I>& ima, const Window<W>& win);
-
+
template <typename I, typename W>
util::array<int>
positive_offsets_wrt(const Image<I>& ima, const Window<W>& win);
-
+
template <typename I, typename W>
util::array<int>
negative_offsets_wrt(const Image<I>& ima, const Window<W>& win);
-
-
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename W, typename I>
- void
- from_to_(const Window<W>& from, Image<I>& to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
@@ -305,7 +294,7 @@ namespace mln
}
ostr << " ]";
}
-
+
} // end of namespace mln::internal
template <typename W>
@@ -323,6 +312,35 @@ namespace mln
}
+ template <typename W, typename I>
+ void
+ from_to_(const Window<W>& win_, Image<I>& ima_)
+ {
+ mln_is_simple_window(W)::check();
+ typedef mln_psite(I) P;
+ mlc_converts_to(mln_dpsite(W), mln_delta(P))::check();
+ mlc_equal(mln_value(I), bool)::check();
+
+ const W& win = exact(win_);
+ I& ima = exact(ima_);
+
+ mln_precondition(win.is_valid());
+ mln_precondition(! ima.is_valid());
+
+ // Hack (below) to avoid circular dependency.
+ ima.init_(mln::internal::geom_bbox(win));
+ {
+ // data::fill(ima, false) is:
+ mln_piter(I) p(ima.domain());
+ for_all(p)
+ ima(p) = false;
+ }
+ unsigned n = win.size();
+ for (unsigned i = 0; i < n; ++i)
+ ima(convert::to<P>(win.dp(i))) = true;
+ }
+
+
template <typename I, typename W>
inline
util::array<int>
@@ -337,7 +355,7 @@ namespace mln
util::array<int> arr;
unsigned n = win.size();
-
+
for (unsigned i = 0; i < n; ++i)
arr.append(ima.delta_index(win.dp(i)));
@@ -359,7 +377,7 @@ namespace mln
util::array<int> arr;
unsigned n = win.size();
-
+
for (unsigned i = 0; i < n; ++i)
{
int offset = ima.delta_index(win.dp(i));
@@ -385,7 +403,7 @@ namespace mln
util::array<int> arr;
unsigned n = win.size();
-
+
for (unsigned i = 0; i < n; ++i)
{
int offset = ima.delta_index(win.dp(i));
@@ -396,45 +414,6 @@ namespace mln
return arr;
}
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename W, typename I>
- void
- from_to_(const Window<W>& win_, Image<I>& ima_)
- {
- mln_is_simple_window(W)::check();
- typedef mln_psite(I) P;
- mlc_converts_to(mln_dpsite(W), mln_delta(P))::check();
- mlc_equal(mln_value(I), bool)::check();
-
- const W& win = exact(win_);
- I& ima = exact(ima_);
-
- mln_precondition(win.is_valid());
- mln_precondition(! ima.is_valid());
-
- // Hack (below) to avoid circular dependency.
- ima.init_(mln::internal::geom_bbox(win));
- {
- // data::fill(ima, false) is:
- mln_piter(I) p(ima.domain());
- for_all(p)
- ima(p) = false;
- }
- unsigned n = win.size();
- for (unsigned i = 0; i < n; ++i)
- ima(convert::to<P>(win.dp(i))) = true;
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
diff --git a/milena/mln/core/dpoint.hh b/milena/mln/core/dpoint.hh
index f4d603e..0e5c0ef 100644
--- a/milena/mln/core/dpoint.hh
+++ b/milena/mln/core/dpoint.hh
@@ -33,7 +33,6 @@
# include <mln/core/def/coord.hh>
# include <mln/core/concept/gdpoint.hh>
# include <mln/core/internal/coord_impl.hh>
-# include <mln/fun/i2v/all.hh>
# include <mln/algebra/vec.hh>
# include <mln/metal/converts_to.hh>
diff --git a/milena/mln/core/image/graph_window_if_piter.hh b/milena/mln/core/image/graph_window_if_piter.hh
index 068fbdb..1060f15 100644
--- a/milena/mln/core/image/graph_window_if_piter.hh
+++ b/milena/mln/core/image/graph_window_if_piter.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2012 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -30,6 +31,7 @@
///
/// \brief Definition of a site iterator on a custom graph window.
+# include <mln/core/concept/window.hh>
# include <mln/core/internal/is_masked_impl_selector.hh>
# include <mln/core/internal/site_relative_iterator_base.hh>
diff --git a/milena/mln/core/image/image1d.hh b/milena/mln/core/image/image1d.hh
index 6d10aa5..53e8611 100644
--- a/milena/mln/core/image/image1d.hh
+++ b/milena/mln/core/image/image1d.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008, 2009, 2011 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2011, 2012 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -122,27 +122,6 @@ namespace mln
template <typename T> struct image1d;
-
- namespace convert
- {
-
- namespace over_load
- {
-
- // histo::array -> image1d.
- template <typename V, typename T>
- void from_to_(const histo::array<V>& from, image1d<T>& to);
-
- // util::array -> image1d.
- template <typename V, typename T>
- void from_to_(const util::array<V>& from, image1d<T>& to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
-
/// Basic 1D image class.
///
/// The parameter \c T is the type of pixel values. This image class
@@ -578,46 +557,6 @@ namespace mln
namespace mln
{
-
- namespace convert
- {
-
- namespace over_load
- {
-
- // histo::array -> image1d.
- template <typename V, typename T>
- inline
- void
- from_to_(const histo::array<V>& from, image1d<T>& to)
- {
- // FIXME: The code should looks like:
-
-// box1d b(point1d(mln_min(V)), point1d(mln_max(V)));
-// ima.init_(b, 0);
-// for_all(v)
-// from_to(h(v), ima.at_( index_of(v) ));
- to.init_(make::box1d(from.nvalues()));
- for (unsigned i = 0; i < from.nvalues(); ++i)
- from_to(from[i], to(point1d(i)));
- }
-
- // util::array -> image1d.
- template <typename V, typename T>
- inline
- void
- from_to_(const util::array<V>& from, image1d<T>& to)
- {
- to.init_(make::box1d(from.nelements()));
- for (unsigned i = 0; i < from.nelements(); ++i)
- from_to(from[i], to(point1d(i)));
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
namespace trait
{
diff --git a/milena/mln/core/internal/neighborhood_base.hh b/milena/mln/core/internal/neighborhood_base.hh
index f1765c9..f96b8f4 100644
--- a/milena/mln/core/internal/neighborhood_base.hh
+++ b/milena/mln/core/internal/neighborhood_base.hh
@@ -42,6 +42,7 @@ namespace mln
// Forward declaration.
+ template <typename W> class neighb;
namespace win
{
template <unsigned n, typename W, typename F>
@@ -66,25 +67,25 @@ namespace mln
/// Give the foreground neighborhood in the case of a dual
/// neighborhood. For instance, with (object:c4, background:c8),
/// the result is c4.
-
+
neighb<W> foreground() const
{
W win = internal::force_exact<E>(*this).win().window_(1); // True, so object.
neighb<W> nbh(win);
return nbh;
}
-
+
/// Give the background neighborhood in the case of a dual
/// neighborhood. For instance, with (object:c4, background:c8),
/// the result is c8.
-
+
neighb<W> background() const
{
W win = internal::force_exact<E>(*this).win().window_(0); // False, so background.
neighb<W> nbh(win);
return nbh;
}
-
+
};
diff --git a/milena/mln/core/mixed_neighb.hh b/milena/mln/core/mixed_neighb.hh
index 7789aba..2c89131 100644
--- a/milena/mln/core/mixed_neighb.hh
+++ b/milena/mln/core/mixed_neighb.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2012 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -50,27 +51,6 @@ namespace mln
// Forward declarations.
template <typename W> class mixed_neighb_fwd_niter;
template <typename W> class mixed_neighb_bkd_niter;
- template <typename W> class mixed_neighb;
-
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename W>
- void
- from_to_(const mln::mixed_neighb<W>& from, W& to);
-
- template <typename W>
- void
- from_to_(const W& from, mln::mixed_neighb<W>& to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
/// Adapter class from window to neighborhood.
@@ -103,6 +83,18 @@ namespace mln
};
+ /// \internal Conversion: mixed_neighb<W> -> W
+ template <typename W>
+ void
+ from_to_(const mln::mixed_neighb<W>& from, W& to);
+
+ /// \internal Conversion: mixed_neighb<W> -> W
+ template <typename W>
+ void
+ from_to_(const W& from, mln::mixed_neighb<W>& to);
+
+
+
// mixed_neighb_fwd_niter<W>
template <typename W>
@@ -167,33 +159,21 @@ namespace mln
}
- // mln::convert::from_to
+ // Conversion
- namespace convert
+ template <typename W>
+ void
+ from_to_(const mln::mixed_neighb<W>& from, W& to)
{
+ to = from.win();
+ }
- namespace over_load
- {
-
- template <typename W>
- void
- from_to_(const mln::mixed_neighb<W>& from, W& to)
- {
- to = from.win();
- }
-
- template <typename W>
- void
- from_to_(const W& from, mln::mixed_neighb<W>& to)
- {
- to.change_window(from);
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
+ template <typename W>
+ void
+ from_to_(const W& from, mln::mixed_neighb<W>& to)
+ {
+ to.change_window(from);
+ }
// mixed_neighb_fwd_niter<W>
diff --git a/milena/mln/core/neighb.hh b/milena/mln/core/neighb.hh
index db31bea..4f348b1 100644
--- a/milena/mln/core/neighb.hh
+++ b/milena/mln/core/neighb.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -47,26 +47,6 @@ namespace mln
// Forward declarations.
template <typename W> class neighb_fwd_niter;
template <typename W> class neighb_bkd_niter;
- template <typename W> class neighb;
-
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename W>
- void
- from_to_(const mln::neighb<W>& from, W& to);
-
- template <typename W>
- void
- from_to_(const W& from, mln::neighb<W>& to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
@@ -99,6 +79,17 @@ namespace mln
};
+ /// \internal Conversions: neighb<W> -> W
+ template <typename W>
+ void
+ from_to_(const mln::neighb<W>& from, W& to);
+
+ /// \internal Conversions: W -> neighb<W>
+ template <typename W>
+ void
+ from_to_(const W& from, mln::neighb<W>& to);
+
+
// neighb_fwd_niter<W>
template <typename W>
@@ -159,35 +150,6 @@ namespace mln
}
- // mln::convert::from_to
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename W>
- void
- from_to_(const mln::neighb<W>& from, W& to)
- {
- to = from.win();
- }
-
- template <typename W>
- void
- from_to_(const W& from, mln::neighb<W>& to)
- {
- to.change_window(from);
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
-
-
// neighb_fwd_niter<W>
template <typename W>
@@ -224,6 +186,20 @@ namespace mln
this->i_.init_(nbh.win(), c);
}
+ template <typename W>
+ void
+ from_to_(const neighb<W>& from, W& to)
+ {
+ to = from.win();
+ }
+
+ template <typename W>
+ void
+ from_to_(const W& from, neighb<W>& to)
+ {
+ to.change_window(from);
+ }
+
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/core/point.hh b/milena/mln/core/point.hh
index d415cf8..03afe57 100644
--- a/milena/mln/core/point.hh
+++ b/milena/mln/core/point.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008, 2009, 2010, 2011 EPITA Research and
+// Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 EPITA Research and
// Development Laboratory (LRDE)
//
// This file is part of Olena.
@@ -41,7 +41,6 @@
# include <mln/core/concept/proxy.hh>
# include <mln/core/concept/gpoint.hh>
# include <mln/core/internal/coord_impl.hh>
-# include <mln/fun/i2v/all_to.hh>
# include <mln/metal/bool.hh>
# include <mln/metal/is_not.hh>
@@ -65,29 +64,6 @@ namespace mln
/// \}
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename G, typename C1, typename C2>
- void from_to_(const point<G,C1>& from, point<G,C2>& to);
-
- template <unsigned n, typename C1, typename G, typename C2>
- void
- from_to_(const mln::algebra::vec<n,C1>& from, point<G,C2>& to);
-
- template <unsigned n, typename C1, typename G>
- void
- from_to_(const mln::algebra::vec<n,C1>& from, point<G,C1>& to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
-
namespace internal
{
// This is a hack so that g++-2.95 can compile the method
@@ -224,6 +200,12 @@ namespace mln
mln::algebra::vec<G::dim, C> coord_;
};
+
+ /// \internal Conversion: point -> point
+ template <typename G, typename C1, typename C2>
+ void from_to_(const point<G,C1>& from, point<G,C2>& to);
+
+
namespace internal
{
@@ -260,126 +242,6 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
- namespace internal
- {
-
- template <typename C, typename C2>
- inline
- C
- convert_data_(metal::bool_<false>, const C2& v)
- {
- return static_cast<C>(v);
- }
-
- template <typename C, typename C2>
- inline
- C
- convert_data_(metal::bool_<true>, const C2& v)
- {
- return static_cast<C>(round(v));
- }
-
- template <typename C, typename C2>
- inline
- C
- convert_data(const C2& v)
- {
- // If (C != float && C != double) && (C2 == float || C2 == double)
- // => We want to round the value.
- // Otherwise we can just statically cast.
- //
- return convert_data_<C>(
- typename mlc_and(
- mlc_and(mlc_is_not(C,float),
- mlc_is_not(C,double)),
- mlc_or(mlc_is(C2,float),
- mlc_is(C2, double)))::eval(), v);
- }
-
-
-
- } // end of namespace mln::internal
-
-
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename G, typename C1, typename C2>
- inline
- void
- from_to_(const point<G,C1>& from, point<G,C2>& to)
- {
- mlc_converts_to(C1,C2)::check();
- enum { dim = G::dim };
-
- for (unsigned i = 0; i < dim; ++i)
- to[i] = mln::internal::convert_data<C2>(from[i]);
- }
-
-
- template <unsigned n, typename C1, typename G, typename C2>
- inline
- void
- from_to_(const mln::algebra::vec<n,C1>& from, point<G,C2>& to)
- {
- mlc_converts_to(C1, C2)::check();
- enum { dim = G::dim };
- mlc_bool(G::dim == n)::check();
-
- unsigned j = 0;
- for (unsigned i = dim - 2; i < dim; ++i)
- to[i] = mln::internal::convert_data<C2>(from[j++]);
- for (unsigned i = 2; i < dim; ++i, ++j)
- to[i-j] = mln::internal::convert_data<C2>(from[j]);
- }
-
- template <typename C1, typename G, typename C2>
- inline
- void
- from_to_(const mln::algebra::vec<1,C1>& from, point<G,C2>& to)
- {
- mlc_converts_to(C1, C2)::check();
- enum { dim = G::dim };
- mlc_bool(G::dim == 1)::check();
-
- to[0] = mln::internal::convert_data<C2>(from[0]);
- }
-
- template <unsigned n, typename C1, typename G>
- inline
- void
- from_to_(const mln::algebra::vec<n,C1>& from, point<G,C1>& to)
- {
- enum { dim = G::dim };
- mlc_bool(G::dim == n)::check();
-
- unsigned j = 0;
- for (unsigned i = dim - 2; i < dim; ++i)
- to[i] = from[j++];
- for (unsigned i = 2; i < dim; ++i, ++j)
- to[i-j] = from[j];
- }
-
- template <typename C1, typename G>
- inline
- void
- from_to_(const mln::algebra::vec<1,C1>& from, point<G,C1>& to)
- {
- enum { dim = G::dim };
- mlc_bool(G::dim == 1)::check();
-
- to[0] = from[0];
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
template <typename G, typename C>
inline
const C& point<G,C>::operator[](unsigned i) const
@@ -426,7 +288,7 @@ namespace mln
inline
point<G,C>::point(const mln::algebra::vec<dim,C2>& v)
{
- convert::over_load::from_to_(v, *this);
+ from_to_(v, *this);
}
@@ -434,7 +296,7 @@ namespace mln
inline
point<G,C>::point(const mln::algebra::vec<dim,C>& v)
{
- convert::over_load::from_to_(v, *this);
+ from_to_(v, *this);
}
@@ -638,6 +500,22 @@ namespace mln
return coord_;
}
+
+ // Conversions
+
+ template <typename G, typename C1, typename C2>
+ inline
+ void
+ from_to_(const point<G,C1>& from, point<G,C2>& to)
+ {
+ mlc_converts_to(C1,C2)::check();
+ enum { dim = G::dim };
+
+ for (unsigned i = 0; i < dim; ++i)
+ to[i] = mln::internal::convert_data<C2>(from[i]);
+ }
+
+
namespace internal
{
diff --git a/milena/mln/core/site_set/operators.hh b/milena/mln/core/site_set/operators.hh
index 89637ad..9cf2509 100644
--- a/milena/mln/core/site_set/operators.hh
+++ b/milena/mln/core/site_set/operators.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -121,8 +122,8 @@ namespace mln
typedef mln_site(Sl) P;
mlc_converts_to(mln_psite(Sr), P)::check();
std::set< P, util::ord<P> > sl, sr, sd;
- convert::over_load::from_to_(lhs, sl);
- convert::over_load::from_to_(rhs, sr);
+ from_to_(lhs, sl);
+ from_to_(rhs, sr);
std::set_symmetric_difference(sl.begin(), sl.end(),
sr.begin(), sr.end(),
std::inserter(sd, sd.begin()),
@@ -136,7 +137,7 @@ namespace mln
to_std_set(const Site_Set<S>& s)
{
std::set< mln_site(S), util::ord<mln_site(S)> > std_s;
- convert::over_load::from_to_(s, std_s);
+ from_to_(s, std_s);
return std_s;
}
@@ -148,8 +149,8 @@ namespace mln
typedef mln_site(Sl) P;
mlc_converts_to(mln_psite(Sr), P)::check();
std::set< P, util::ord<P> > sl, sr;
- convert::over_load::from_to_(lhs, sl);
- convert::over_load::from_to_(rhs, sr);
+ from_to_(lhs, sl);
+ from_to_(rhs, sr);
return std::includes(sr.begin(), sr.end(),
sl.begin(), sl.end(),
util::ord<P>());
diff --git a/milena/mln/core/site_set/p_centered.hh b/milena/mln/core/site_set/p_centered.hh
index 4c4efd9..cf2bd5c 100644
--- a/milena/mln/core/site_set/p_centered.hh
+++ b/milena/mln/core/site_set/p_centered.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -34,7 +35,7 @@
/// \todo Add the bkd iter.
/// \todo Code is_valid() and change_target() for the site set.
-
+# include <mln/core/concept/window.hh>
# include <mln/core/internal/site_set_base.hh>
# include <mln/core/internal/site_set_iterator_base.hh>
diff --git a/milena/mln/core/site_set/p_vaccess.hh b/milena/mln/core/site_set/p_vaccess.hh
index 677ae2b..d7a753c 100644
--- a/milena/mln/core/site_set/p_vaccess.hh
+++ b/milena/mln/core/site_set/p_vaccess.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -31,6 +32,7 @@
/// \todo Fix the FIXMEs.
# include <utility>
+# include <vector>
# include <mln/core/concept/site_set.hh>
# include <mln/core/site_set/p_double.hh>
# include <mln/core/internal/site_set_base.hh>
diff --git a/milena/mln/core/w_window.hh b/milena/mln/core/w_window.hh
index d463697..1022dd5 100644
--- a/milena/mln/core/w_window.hh
+++ b/milena/mln/core/w_window.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -55,29 +56,6 @@ namespace mln
template <typename It, typename W> struct with_w_;
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename I, typename D, typename W>
- void
- from_to_(const Image<I>& from, w_window<D,W>& to);
-
- template <typename D, typename W, typename I>
- void
- from_to_(const w_window<D,W>& from, Image<I>& to);
-
- template <typename V, unsigned S, typename D, typename W>
- void
- from_to_(const V (&weight)[S], w_window<D,W>& to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
namespace trait
{
@@ -164,6 +142,15 @@ namespace mln
bool operator==(const w_window<D,Wl>& lhs, const w_window<D,Wr>& rhs);
+ /// \internal Conversions: w_window -> image
+ template <typename D, typename W, typename I>
+ void from_to_(const w_window<D,W>& from, Image<I>& to);
+
+ /// \internal Conversions: weight[] -> w_window
+ template <typename V, unsigned S, typename D, typename W>
+ void from_to_(const V (&weight)[S], w_window<D,W>& to);
+
+
/// Decorator to handle weights for iterators on window points.
template <typename It, typename W>
@@ -195,7 +182,7 @@ namespace mln
wei_(ds.weights())
{
}
-
+
template <typename It, typename W>
inline
W
@@ -312,107 +299,6 @@ namespace mln
}
- // convert::from_to_
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename I, typename D, typename W>
- void
- from_to_(const Image<I>& from_, w_window<D,W>& to)
- {
- mlc_converts_to(mln_deduce(I, psite, delta), D)::check();
- mlc_converts_to(mln_value(I), W)::check();
- const I& ima = exact(from_);
- to.clear();
- mln_value(I) zero = literal::zero;
- mln_piter(I) p(ima.domain());
- for_all(p)
- if (ima(p) != zero)
- to.insert(ima(p), convert::to<D>(p));
- }
-
- template <typename D, typename W, typename I>
- void
- from_to_(const w_window<D,W>& w_win, Image<I>& ima_)
- {
- typedef mln_site(I) P;
- mlc_converts_to(D, mln_delta(P))::check();
- mlc_converts_to(W, mln_value(I))::check();
-
- I& ima = exact(ima_);
- mln_precondition(! ima.is_valid());
- mln_precondition(w_win.is_valid());
-
- ima.init_(geom::bbox(w_win));
- {
- // data::fill(ima, literal::zero) is:
- mln_value(I) zero = literal::zero;
- mln_piter(I) p(ima.domain());
- for_all(p)
- ima(p) = zero;
- }
-
- unsigned n = w_win.size();
- for (unsigned i = 0; i < n; ++i)
- ima(convert::to<P>(w_win.dp(i))) = w_win.w(i);
- }
-
- // FIXME: Sample code (below) to generalize the code above:
-
-// template <typename W>
-// inline
-// mln_image_from(W, mln_weight(W)) to_image(const Weighted_Window<W>& w_win_)
-// {
-// const W& w_win = exact(w_win_);
-// mln_precondition(! w_win.is_empty());
-
-// typedef mln_psite(W) P;
-// box<P> b = geom::bbox(w_win);
-// mln_image_from(W, mln_weight(W)) ima(b);
-// // Fill the image with zeros, as (weighted) windows are not
-// // necessarily box-shaped (there might be holes corresponding to
-// // null weights).
-// data::fill(ima, literal::zero);
-// P O = P::origin;
-// mln_qiter(W) q(w_win, O);
-// for_all(q)
-// ima(q) = q.w();
-// return ima;
-// }
-
- template <typename V, unsigned S, typename D, typename W>
- void
- from_to_(const V (&weight)[S], w_window<D,W>& to)
- {
- mlc_bool(S != 0)::check();
- mlc_converts_to(V, W)::check();
- enum { d = D::dim,
- s = mlc_root(d,S)::value / 2 };
- metal::bool_<(mlc_pow_int(2 * s + 1, d) == S)>::check();
- to.clear();
- typedef mln_site(D) P;
- box<P> b(all_to(-s), all_to(+s));
- mln_fwd_piter(box<P>) p(b);
- unsigned i = 0;
- V zero = literal::zero;
- for_all(p)
- {
- if (weight[i] != zero)
- to.insert(weight[i], convert::to<D>(p));
- ++i;
- }
-
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
// operators
template <typename D, typename W>
@@ -442,6 +328,59 @@ namespace mln
return true;
}
+
+ // Conversions
+
+ template <typename D, typename W, typename I>
+ void
+ from_to_(const w_window<D,W>& w_win, Image<I>& ima_)
+ {
+ typedef mln_site(I) P;
+ mlc_converts_to(D, mln_delta(P))::check();
+ mlc_converts_to(W, mln_value(I))::check();
+
+ I& ima = exact(ima_);
+ mln_precondition(! ima.is_valid());
+ mln_precondition(w_win.is_valid());
+
+ ima.init_(geom::bbox(w_win));
+ {
+ // data::fill(ima, literal::zero) is:
+ mln_value(I) zero = literal::zero;
+ mln_piter(I) p(ima.domain());
+ for_all(p)
+ ima(p) = zero;
+ }
+
+ unsigned n = w_win.size();
+ for (unsigned i = 0; i < n; ++i)
+ ima(convert::to<P>(w_win.dp(i))) = w_win.w(i);
+ }
+
+ template <typename V, unsigned S, typename D, typename W>
+ void
+ from_to_(const V (&weight)[S], w_window<D,W>& to)
+ {
+ mlc_bool(S != 0)::check();
+ mlc_converts_to(V, W)::check();
+ enum { d = D::dim,
+ s = mlc_root(d,S)::value / 2 };
+ metal::bool_<(mlc_pow_int(2 * s + 1, d) == S)>::check();
+ to.clear();
+ typedef mln_site(D) P;
+ box<P> b(all_to(-s), all_to(+s));
+ mln_fwd_piter(box<P>) p(b);
+ unsigned i = 0;
+ V zero = literal::zero;
+ for_all(p)
+ {
+ if (weight[i] != zero)
+ to.insert(weight[i], convert::to<D>(p));
+ ++i;
+ }
+
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
diff --git a/milena/mln/fun/i2v/array.hh b/milena/mln/fun/i2v/array.hh
index 21ddbac..a0e392a 100644
--- a/milena/mln/fun/i2v/array.hh
+++ b/milena/mln/fun/i2v/array.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -49,38 +50,9 @@ namespace mln
} // end of namespace mln::fun::i2v
} // end of namespace mln::fun
-
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename T>
- inline
- void
- from_to_(const util::array<T>& from, fun::i2v::array<T>& to);
-
- template <typename T, typename U>
- inline
- void
- from_to_(const util::array<T>& from, fun::i2v::array<U>& to);
-
- template <typename T>
- inline
- void
- from_to_(const std::vector<T>& from, fun::i2v::array<T>& to);
-
- template <typename T, typename U>
- inline
- void
- from_to_(const std::vector<T>& from, fun::i2v::array<U>& to);
-
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ namespace util {
+ template <typename T> class array;
+ }
namespace fun
@@ -158,14 +130,41 @@ namespace mln
const array<T>& a);
+ /// \internal Conversion: fun::i2v::array -> util::array
+ template <typename T1, typename T2>
+ void
+ from_to_(const fun::i2v::array<T1>& from, util::array<T2>& to);
+
} // end of namespace mln::fun::i2v
} // end of namespace mln::fun
+} // end of namespace mln
+
+
+namespace std
+{
+
+ /// \internal Conversion: std::vectorfun::i2v::array<T> -> fun::i2v::array<T>
+ template <typename T>
+ inline
+ void
+ from_to_(const vector<T>& from, mln::fun::i2v::array<T>& to);
+
+ /// \internal Conversion: std::vector<T> -> mln::fun::i2v::array<U>
+ template <typename T, typename U>
+ inline
+ void
+ from_to_(const vector<T>& from, mln::fun::i2v::array<U>& to);
+
+} // end of namespace std
# ifndef MLN_INCLUDE_ONLY
+namespace mln
+{
+
// Init.
template <typename T1, typename T2>
@@ -177,57 +176,6 @@ namespace mln
}
- // convert::from_to
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename T>
- inline
- void
- from_to_(const util::array<T>& from, fun::i2v::array<T>& to)
- {
- to = fun::i2v::array<T>(from);
- }
-
- template <typename T, typename U>
- inline
- void
- from_to_(const util::array<T>& from, fun::i2v::array<U>& to)
- {
- to.resize(from.nelements());
- for (unsigned i = 0; i < from.nelements(); ++i)
- to(i) = convert::to<U>(from[i]);
- }
-
- template <typename T>
- inline
- void
- from_to_(const std::vector<T>& from, fun::i2v::array<T>& to)
- {
- to = fun::i2v::array<T>(from);
- }
-
- template <typename T, typename U>
- inline
- void
- from_to_(const std::vector<T>& from, fun::i2v::array<U>& to)
- {
- to.resize(from.nelements());
- for (unsigned i = 0; i < from.size(); ++i)
- to(i) = convert::to<U>(from[i]);
- }
-
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
-
/// fun::i2v::array
namespace fun
@@ -366,6 +314,18 @@ namespace mln
}
+ // Conversion
+
+ template <typename T1, typename T2>
+ void
+ from_to_(const array<T1>& from, util::array<T2>& to)
+ {
+ to.resize(from.size());
+
+ for (unsigned i = 0; i < from.size(); ++i)
+ to[i] = convert::to<T2>(from(i));
+ }
+
} // end of namespace mln::fun::i2v
} // end of namespace mln::fun
@@ -379,9 +339,31 @@ namespace mln
return tmp;
}
-# endif // ! MLN_INCLUDE_ONLY
-
} // end of namespace mln
+namespace std
+{
+
+ template <typename T>
+ inline
+ void
+ from_to_(const vector<T>& from, mln::fun::i2v::array<T>& to)
+ {
+ to = mln::fun::i2v::array<T>(from);
+ }
+
+ template <typename T, typename U>
+ inline
+ void
+ from_to_(const vector<T>& from, mln::fun::i2v::array<U>& to)
+ {
+ to.resize(from.nelements());
+ for (unsigned i = 0; i < from.size(); ++i)
+ to(i) = mln::convert::to<U>(from[i]);
+ }
+
+} // end of namespace std
+
+# endif // ! MLN_INCLUDE_ONLY
#endif // ! MLN_FUN_I2V_ARRAY_HH
diff --git a/milena/mln/fun/v2v/hsl_to_rgb.hh b/milena/mln/fun/v2v/hsl_to_rgb.hh
index dbedcf4..3a606d0 100644
--- a/milena/mln/fun/v2v/hsl_to_rgb.hh
+++ b/milena/mln/fun/v2v/hsl_to_rgb.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008, 2009, 2011 EPITA Research and Development
+// Copyright (C) 2008, 2009, 2011, 2012 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -48,14 +48,6 @@
namespace mln
{
- // Forward declarations
- namespace value
- {
- template <typename H, typename S, typename L> class hsl_;
- typedef hsl_<float, float, float> hsl_f;
- template <unsigned n> struct rgb;
- }
-
namespace fun
{
diff --git a/milena/mln/fun/v2v/rgb_to_hsl.hh b/milena/mln/fun/v2v/rgb_to_hsl.hh
index 7ec9b72..11339fd 100644
--- a/milena/mln/fun/v2v/rgb_to_hsl.hh
+++ b/milena/mln/fun/v2v/rgb_to_hsl.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008, 2009, 2011 EPITA Research and Development
+// Copyright (C) 2008, 2009, 2011, 2012 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -35,8 +35,6 @@
# include <mln/trait/value_.hh>
-# include <mln/value/rgb.hh>
-
namespace mln
{
diff --git a/milena/mln/histo/array.hh b/milena/mln/histo/array.hh
index 0f4ed77..b60bad3 100644
--- a/milena/mln/histo/array.hh
+++ b/milena/mln/histo/array.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -35,10 +36,17 @@
# include <mln/value/set.hh>
+// For conversion
+# include <mln/convert/from_to.hh>
+# include <mln/make/box1d.hh>
+
namespace mln
{
+ // Forward declaration
+ template <typename T> struct image1d;
+
namespace histo
{
@@ -76,8 +84,9 @@ namespace mln
template <typename T>
std::ostream& operator<<(std::ostream& ostr, const array<T>& h);
-
-
+ /// \internal Conversion: histo::array -> image1d.
+ template <typename V, typename T>
+ void from_to_(const array<V>& from, image1d<T>& to);
# ifndef MLN_INCLUDE_ONLY
@@ -185,6 +194,25 @@ namespace mln
return ostr;
}
+
+ // Conversions
+
+ template <typename V, typename T>
+ inline
+ void
+ from_to_(const array<V>& from, image1d<T>& to)
+ {
+ // FIXME: The code should looks like:
+
+// box1d b(point1d(mln_min(V)), point1d(mln_max(V)));
+// ima.init_(b, 0);
+// for_all(v)
+// from_to(h(v), ima.at_( index_of(v) ));
+ to.init_(make::box1d(from.nvalues()));
+ for (unsigned i = 0; i < from.nvalues(); ++i)
+ convert::from_to(from[i], to(point1d(i)));
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::histo
diff --git a/milena/mln/io/magick/save.hh b/milena/mln/io/magick/save.hh
index d3c4aa6..80b20df 100644
--- a/milena/mln/io/magick/save.hh
+++ b/milena/mln/io/magick/save.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2009, 2010, 2011 EPITA Research and Development
+// Copyright (C) 2009, 2010, 2011, 2012 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -42,12 +42,16 @@
# include <mln/metal/equal.hh>
-# include <mln/core/concept/image.hh>
+# include <mln/core/alias/dpoint2d.hh>
+# include <mln/core/pixter2d.hh>
# include <mln/value/int_u8.hh>
# include <mln/value/rgb8.hh>
# include <mln/value/qt/rgb32.hh>
+# include <mln/geom/nrows.hh>
+# include <mln/geom/ncols.hh>
+
namespace mln
{
diff --git a/milena/mln/io/plot/save.hh b/milena/mln/io/plot/save.hh
index d217915..b16499b 100644
--- a/milena/mln/io/plot/save.hh
+++ b/milena/mln/io/plot/save.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2009, 2010, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -35,6 +35,7 @@
# include <fstream>
# include <mln/core/image/image1d.hh>
# include <mln/util/array.hh>
+# include <mln/histo/array.hh>
namespace mln
diff --git a/milena/mln/labeling/blobs_and_compute.hh b/milena/mln/labeling/blobs_and_compute.hh
index e8f784c..744d411 100644
--- a/milena/mln/labeling/blobs_and_compute.hh
+++ b/milena/mln/labeling/blobs_and_compute.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2009, 2010, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -38,6 +38,7 @@
# include <mln/labeling/blobs.hh>
# include <mln/labeling/compute.hh>
+# include <mln/util/couple.hh>
namespace mln
{
diff --git a/milena/mln/labeling/value_and_compute.hh b/milena/mln/labeling/value_and_compute.hh
index d93fce9..e82d8f4 100644
--- a/milena/mln/labeling/value_and_compute.hh
+++ b/milena/mln/labeling/value_and_compute.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2010, 2012 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -34,6 +35,8 @@
# include <mln/core/concept/neighborhood.hh>
# include <mln/canvas/labeling/video.hh>
# include <mln/data/fill.hh>
+# include <mln/util/array.hh>
+# include <mln/util/couple.hh>
diff --git a/milena/mln/make/w_window2d.hh b/milena/mln/make/w_window2d.hh
index 663f9ed..24e086d 100644
--- a/milena/mln/make/w_window2d.hh
+++ b/milena/mln/make/w_window2d.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -33,7 +34,7 @@
# include <mln/core/w_window.hh>
# include <mln/core/alias/dpoint2d.hh>
-# include <mln/convert/from_to.hxx>
+# include <mln/convert/from_to.hh>
namespace mln
diff --git a/milena/mln/util/array.hh b/milena/mln/util/array.hh
index c7febfe..76c05fe 100644
--- a/milena/mln/util/array.hh
+++ b/milena/mln/util/array.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008, 2009, 2011 EPITA Research and Development
+// Copyright (C) 2008, 2009, 2011, 2012 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -38,6 +38,7 @@
# include <iostream>
# include <algorithm>
+# include <mln/core/alias/box1d.hh>
# include <mln/core/concept/function.hh>
# include <mln/core/concept/proxy.hh>
# include <mln/core/concept/iterator.hh>
@@ -48,34 +49,14 @@
namespace mln
{
- namespace util
- {
-
- /// Forward declaration.
- template <typename T>
- class array;
-
- } // end of namespace mln::util
-
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename T1, typename T2>
- void
- from_to_(const util::array<T1>& from, util::array<T2>& to);
-
- template <typename T1, typename T2>
- void
- from_to_(const fun::i2v::array<T1>& from, util::array<T2>& to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
+ // Forward declarations.
+ namespace fun {
+ namespace i2v {
+ template <typename T> class array;
+ }
+ }
+ template <typename V> struct image1d;
+ // End of forward declarations
namespace util
@@ -97,7 +78,7 @@ namespace mln
//
template <typename T>
class array
- : public fun::internal::selector_from_result_<T, array<T> >::ret
+ : public mln::fun::internal::selector_from_result_<T, array<T> >::ret
// public Function_v2v< mln::util::array<T> >
{
@@ -225,6 +206,28 @@ namespace mln
const array<T>& rhs);
+ /// \internal Conversion: array -> array
+ template <typename T1, typename T2>
+ void
+ from_to_(const array<T1>& from, array<T2>& to);
+
+ /// \internal Conversion: array<T> -> fun::i2v::array<T>
+ template <typename T>
+ inline
+ void
+ from_to_(const array<T>& from, fun::i2v::array<T>& to);
+
+ /// \internal Conversion: array<T> -> fun::i2v::array<U>
+ template <typename T, typename U>
+ inline
+ void
+ from_to_(const array<T>& from, fun::i2v::array<U>& to);
+
+ /// \internal Conversion: util::array -> image1d.
+ template <typename V, typename T>
+ void from_to_(const util::array<V>& from, image1d<T>& to);
+
+
// array_fwd_iter<T>
template <typename T>
@@ -382,40 +385,6 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
- // convert::from_to_
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename T1, typename T2>
- void
- from_to_(const util::array<T1>& from, util::array<T2>& to)
- {
- to.resize(from.nelements());
-
- for (unsigned i = 0; i < from.nelements(); ++i)
- to[i] = convert::to<T2>(from[i]);
- }
-
- template <typename T1, typename T2>
- void
- from_to_(const fun::i2v::array<T1>& from, util::array<T2>& to)
- {
- to.resize(from.size());
-
- for (unsigned i = 0; i < from.size(); ++i)
- to[i] = convert::to<T2>(from(i));
- }
-
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
namespace util
{
@@ -605,6 +574,47 @@ namespace mln
}
+ // Conversions
+
+ template <typename T1, typename T2>
+ void
+ from_to_(const array<T1>& from, array<T2>& to)
+ {
+ to.resize(from.nelements());
+
+ for (unsigned i = 0; i < from.nelements(); ++i)
+ to[i] = convert::to<T2>(from[i]);
+ }
+
+ template <typename T>
+ inline
+ void
+ from_to_(const array<T>& from, fun::i2v::array<T>& to)
+ {
+ to = fun::i2v::array<T>(from);
+ }
+
+ template <typename T, typename U>
+ inline
+ void
+ from_to_(const array<T>& from, fun::i2v::array<U>& to)
+ {
+ to.resize(from.nelements());
+ for (unsigned i = 0; i < from.nelements(); ++i)
+ to(i) = convert::to<U>(from[i]);
+ }
+
+ template <typename V, typename T>
+ inline
+ void
+ from_to_(const array<V>& from, image1d<T>& to)
+ {
+ to.init_(make::box1d(from.nelements()));
+ for (unsigned i = 0; i < from.nelements(); ++i)
+ from_to(from[i], to(point1d(i)));
+ }
+
+
// util::array_fwd_iter<T>
diff --git a/milena/mln/util/object_id.hh b/milena/mln/util/object_id.hh
index 525ff15..1d2b361 100644
--- a/milena/mln/util/object_id.hh
+++ b/milena/mln/util/object_id.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2009, 2011 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2009, 2011, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -39,24 +39,6 @@
namespace mln
{
- // Forward declaration
- namespace util { template <typename Tag, typename V> class object_id; }
-
- namespace convert
- {
-
- namespace over_load
- {
-
- // object_id<Tag,V> -> V.
- template <typename Tag, typename V>
- void from_to_(const util::object_id<Tag,V>& from, V& to_);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
namespace util
{
@@ -109,6 +91,10 @@ namespace mln
bool
operator<(const object_id<Tag,V>& lhs, const object_id<Tag,V>& rhs);
+ /// \internal Conversion: object_id<Tag,V> -> V.
+ template <typename Tag, typename V>
+ void from_to_(const util::object_id<Tag,V>& from, V& to_);
+
} // end of namespace mln::util
# ifndef MLN_INCLUDE_ONLY
@@ -228,24 +214,16 @@ namespace mln
return lhs.value() < rhs.value();
}
- } // end of namespace mln::util
- namespace convert
- {
+ // Conversions
- namespace over_load
+ template <typename Tag, typename V>
+ void from_to_(const util::object_id<Tag,V>& from, V& to_)
{
+ to_ = from.value();
+ }
- // object_id<Tag,V> -> V.
- template <typename Tag, typename V>
- void from_to_(const util::object_id<Tag,V>& from, V& to_)
- {
- to_ = from.value();
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ } // end of namespace mln::util
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/value/hsl.hh b/milena/mln/value/hsl.hh
index 0901904..6f716f4 100644
--- a/milena/mln/value/hsl.hh
+++ b/milena/mln/value/hsl.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -32,43 +33,23 @@
#include <mln/value/int_u.hh>
#include <mln/algebra/vec.hh>
-// Used in from_to
-#include <mln/fun/v2v/rgb_to_hsl.hh>
-
namespace mln
{
// Forward declarations.
- namespace value
- {
-
- template <typename H, typename S, typename L>
- class hsl_;
-
+ namespace value {
+ namespace qt {
+ struct rgb32;
+ }
+ template <typename H, typename S, typename L> class hsl_;
}
+} // end of namespace mln
- namespace convert
- {
-
- namespace over_load
- {
-
- // rgb to hsl_
- void
- from_to_(const value::rgb<16>& from, value::hsl_<float,float,float>& to);
-
- // rgb to hsl_
- void
- from_to_(const value::rgb<8>& from, value::hsl_<float,float,float>& to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
+namespace mln
+{
namespace trait
{
@@ -251,6 +232,17 @@ namespace mln
operator==(const hsl_<H,S,L>& lhs, const hsl_<H,S,L>& rhs);
/// \}
+
+ // Conversions
+
+ /// \internal Conversion: hsl -> qt::rgb32.
+ template <typename H, typename S, typename L>
+ void from_to_(const hsl_<H,S,L>& from, qt::rgb32& to);
+
+ /// \internal Conversion: hsl -> rgb8.
+ template <typename H, typename S, typename L>
+ void from_to_(const value::hsl_<H,S,L>&, value::rgb<8>& to);
+
} // end of namespace mln::value
@@ -261,19 +253,31 @@ namespace mln
namespace v2v
{
- template <typename T_hsl>
- struct f_rgb_to_hsl_;
+ template <typename T_rgb>
+ struct f_hsl_to_rgb_;
- typedef f_rgb_to_hsl_<value::hsl_f> f_rgb_to_hsl_f_t;
+ typedef f_hsl_to_rgb_< value::rgb<8> > f_hsl_to_rgb_3x8_t;
+// typedef f_hsl_to_rgb_< value::rgb<16> > f_hsl_to_rgb_3x16_t;
- extern f_rgb_to_hsl_f_t f_rgb_to_hsl_f;
+ extern f_hsl_to_rgb_3x8_t f_hsl_to_rgb_3x8;
+// extern f_hsl_to_rgb_3x16_t f_hsl_to_rgb_3x16;
}
}
+} // end of namespace mln
+
+
+// Used in from_to
+# include <mln/value/rgb.hh>
+# include <mln/fun/v2v/hsl_to_rgb.hh>
+
+
# ifndef MLN_INCLUDE_ONLY
+namespace mln
+{
namespace value
{
@@ -380,32 +384,24 @@ namespace mln
&& lhs.lum() == rhs.lum();
}
- } // end of namespace mln::value
-
- namespace convert
- {
+ // Conversions
- namespace over_load
+ template <typename H, typename S, typename L>
+ void from_to_(const hsl_<H,S,L>& from, qt::rgb32& to)
{
+ rgb<8> v = fun::v2v::f_hsl_to_rgb_3x8(from);
+ to = v.to_equiv();
+ }
- inline
- void
- from_to_(const value::rgb<16>& from, value::hsl_<float,float,float>& to)
- {
- to = fun::v2v::f_rgb_to_hsl_f(from);
- }
-
- inline
- void
- from_to_(const value::rgb<8>& from, value::hsl_<float,float,float>& to)
- {
- to = fun::v2v::f_rgb_to_hsl_f(from);
- }
-
- } // end of namespace mln::convert::over_load
+ template <typename H, typename S, typename L>
+ void
+ from_to_(const hsl_<H,S,L>& from, rgb<8>& to)
+ {
+ to = fun::v2v::f_hsl_to_rgb_3x8(from);
+ }
- } // end of namespace mln::convert
+ } // end of namespace mln::value
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/value/int_u.hh b/milena/mln/value/int_u.hh
index f3786f9..d051c13 100644
--- a/milena/mln/value/int_u.hh
+++ b/milena/mln/value/int_u.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008, 2009, 2010 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2010, 2012 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -31,8 +31,6 @@
///
/// Define a generic class for unsigned integers.
-# include <mln/trait/all.hh> // FIXME!
-
# include <mln/value/ops.hh>
# include <mln/metal/math/pow.hh>
@@ -48,19 +46,21 @@
namespace mln
{
- namespace value
- {
- // Forward declaration.
+ // Forward declarations.
+ namespace value {
+ namespace qt {
+ struct rgb32;
+ }
template <unsigned n> struct int_u;
+ template <unsigned n> struct rgb;
}
namespace literal
{
- // Forward declarations.
struct zero_t;
struct one_t;
}
-
+ // End of forward declarations
namespace trait
{
@@ -110,42 +110,6 @@ namespace mln
} // end of namespace mln::trait
- namespace convert
- {
-
- namespace over_load
- {
-
- // int_u -> unsigned.
- template <unsigned n>
- void
- from_to_(const value::int_u<n>& from, unsigned& to_);
-
-
- // int_u -> bool.
- template <unsigned n>
- void
- from_to_(const value::int_u<n>& from, bool& to_);
-
-
- // int_u -> float.
- template <unsigned n>
- void
- from_to_(const value::int_u<n>& from, float& to_);
-
-
- // int_u -> double.
- template <unsigned n>
- void
- from_to_(const value::int_u<n>& from, double& to_);
-
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
-
namespace value
{
@@ -216,57 +180,41 @@ namespace mln
template <unsigned n>
std::istream& operator>>(std::istream& istr, int_u<n>& i);
- } // end of namespace mln::value
-# ifndef MLN_INCLUDE_ONLY
- namespace convert
- {
+ // Conversions
- namespace over_load
- {
+ /// \internal Conversion: int_u -> unsigned.
+ template <unsigned n>
+ void from_to_(const int_u<n>& from, unsigned& to_);
- // int_u -> unsigned.
- template <unsigned n>
- inline
- void
- from_to_(const value::int_u<n>& from, unsigned& to_)
- {
- to_ = from;
- }
- // int_u -> bool.
- template <unsigned n>
- inline
- void
- from_to_(const value::int_u<n>& from, bool& to_)
- {
- to_ = (from != 0u);
- }
+ /// \internal Conversion: int_u -> bool.
+ template <unsigned n>
+ void from_to_(const int_u<n>& from, bool& to_);
- // int_u -> float.
- template <unsigned n>
- inline
- void
- from_to_(const value::int_u<n>& from, float& to_)
- {
- to_ = static_cast<float>(from);
- }
- // int_u -> double.
- template <unsigned n>
- inline
- void
- from_to_(const value::int_u<n>& from, double& to_)
- {
- to_ = static_cast<double>(from);
- }
+ /// \internal Conversion: int_u -> float.
+ template <unsigned n>
+ void from_to_(const int_u<n>& from, float& to_);
- } // end of namespace mln::convert::over_load
+ /// \internal Conversion: int_u -> double.
+ template <unsigned n>
+ void
+ from_to_(const int_u<n>& from, double& to_);
- } // end of namespace mln::convert
+ /// \internal Conversion: Conversion: int_u -> rgb.
+ template <unsigned m>
+ void from_to_(const int_u<m>& from, qt::rgb32& to);
+ /// \internal Conversion: int_u -> rgb.
+ template <unsigned m>
+ void from_to_(const int_u<m>& from, rgb<m>& to);
+
+ } // end of namespace mln::value
+
+# ifndef MLN_INCLUDE_ONLY
namespace value
{
@@ -367,6 +315,56 @@ namespace mln
return istr >> i.handle_();
}
+
+ // Conversions
+
+ template <unsigned n>
+ inline
+ void
+ from_to_(const int_u<n>& from, unsigned& to_)
+ {
+ to_ = from;
+ }
+
+ template <unsigned n>
+ inline
+ void
+ from_to_(const int_u<n>& from, bool& to_)
+ {
+ to_ = (from != 0u);
+ }
+
+ template <unsigned n>
+ inline
+ void
+ from_to_(const int_u<n>& from, float& to_)
+ {
+ to_ = static_cast<float>(from);
+ }
+
+ template <unsigned n>
+ inline
+ void
+ from_to_(const int_u<n>& from, double& to_)
+ {
+ to_ = static_cast<double>(from);
+ }
+
+ template <unsigned m>
+ void
+ from_to_(const int_u<m>& from, qt::rgb32& to)
+ {
+ mlc_bool(m <= 8)::check();
+ to = qt::rgb32(from, from, from);
+ }
+
+ template <unsigned m>
+ void
+ from_to_(const int_u<m>& from, rgb<m>& to)
+ {
+ to = rgb<m>(from, from, from);
+ }
+
} // end of namespace mln::value
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/value/label.hh b/milena/mln/value/label.hh
index 5c983e5..dd0f924 100644
--- a/milena/mln/value/label.hh
+++ b/milena/mln/value/label.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008, 2009, 2010, 2011 EPITA Research and
+// Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 EPITA Research and
// Development Laboratory (LRDE)
//
// This file is part of Olena.
@@ -91,43 +91,6 @@ namespace mln
} // end of namespace trait
-
- namespace convert
- {
-
- namespace over_load
- {
-
- // int_u -> label.
- template <unsigned n>
- void
- from_to_(const value::int_u<n>& from, value::label<n>& to_);
-
- // label -> int_u.
- template <unsigned n>
- void
- from_to_(const value::label<n>& from, value::int_u<n>& to_);
-
-
- // int_u -> label.
- template <unsigned n, unsigned m>
- void
- from_to_(const value::int_u<n>& from, value::label<m>& to_);
-
- // label -> bool.
- template <unsigned n>
- void
- from_to_(const value::label<n>& from, bool& to_);
-
- // label -> unsigned.
- template <unsigned n>
- void
- from_to_(const value::label<n>& from, unsigned& to_);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
namespace value
{
@@ -197,70 +160,32 @@ namespace mln
std::ostream& operator<<(std::ostream& ostr, const label<n>& l);
- } // end of namespace mln::value
-
-
-# ifndef MLN_INCLUDE_ONLY
-
-
- namespace convert
- {
-
- namespace over_load
- {
-
- // int_u -> label.
- template <unsigned n>
- inline
- void
- from_to_(const value::int_u<n>& from, value::label<n>& to_)
- {
- to_ = from;
- }
+ /// \internal Conversion: int_u -> label.
+ template <unsigned n>
+ void from_to_(const value::int_u<n>& from, value::label<n>& to_);
- // label -> int_u.
- template <unsigned n>
- void
- from_to_(const value::label<n>& from, value::int_u<n>& to_)
- {
- to_ = from;
- }
+ /// \internal Conversion: label -> int_u.
+ template <unsigned n>
+ void from_to_(const value::label<n>& from, value::int_u<n>& to_);
- // int_u<n> -> label<m> with n < m.
- template <unsigned n, unsigned m>
- inline
- void
- from_to_(const value::int_u<n>& from, value::label<m>& to_)
- {
- enum { valid = n < m };
- metal::bool_<valid>::check();
- to_ = from;
- }
+ /// \internal Conversion: int_u -> label.
+ template <unsigned n, unsigned m>
+ void from_to_(const value::int_u<n>& from, value::label<m>& to_);
- // int_u<n> -> bool
- template <unsigned n>
- inline
- void
- from_to_(const value::label<n>& from, bool& to_)
- {
- to_ = (from != 0u);
- }
+ /// \internal Conversion: label -> bool.
+ template <unsigned n>
+ void from_to_(const value::label<n>& from, bool& to_);
- // int_u<n> -> unsigned
- template <unsigned n>
- inline
- void
- from_to_(const value::label<n>& from, unsigned& to_)
- {
- to_ = from;
- }
+ /// \internal Conversion: label -> unsigned.
+ template <unsigned n>
+ void from_to_(const value::label<n>& from, unsigned& to_);
- } // end of namespace mln::convert::over_load
+ } // end of namespace mln::value
- } // end of namespace mln::convert
+# ifndef MLN_INCLUDE_ONLY
namespace value
@@ -355,6 +280,47 @@ namespace mln
return ostr << debug::format(i.to_equiv());
}
+ template <unsigned n>
+ inline
+ void
+ from_to_(const value::int_u<n>& from, value::label<n>& to_)
+ {
+ to_ = from;
+ }
+
+ template <unsigned n>
+ void
+ from_to_(const value::label<n>& from, value::int_u<n>& to_)
+ {
+ to_ = from;
+ }
+
+ template <unsigned n, unsigned m>
+ inline
+ void
+ from_to_(const value::int_u<n>& from, value::label<m>& to_)
+ {
+ enum { valid = n < m };
+ metal::bool_<valid>::check();
+ to_ = from;
+ }
+
+ template <unsigned n>
+ inline
+ void
+ from_to_(const value::label<n>& from, bool& to_)
+ {
+ to_ = (from != 0u);
+ }
+
+ template <unsigned n>
+ inline
+ void
+ from_to_(const value::label<n>& from, unsigned& to_)
+ {
+ to_ = from;
+ }
+
} // end of namespace mln::value
diff --git a/milena/mln/value/qt/rgb32.hh b/milena/mln/value/qt/rgb32.hh
index 511d6a7..67bf1eb 100644
--- a/milena/mln/value/qt/rgb32.hh
+++ b/milena/mln/value/qt/rgb32.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2010, 2012 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -75,34 +76,6 @@ namespace mln
/// \}
}
-
- namespace convert
- {
-
- namespace over_load
- {
-
- // int_u -> rgb.
- template <unsigned m>
- void from_to_(const value::int_u<m>& from, value::qt::rgb32& to);
-
- // hsl -> rgb32.
- template <typename H, typename S, typename L>
- void from_to_(const value::hsl_<H,S,L>&, value::qt::rgb32& to);
-
- // rgb32 -> bool.
- void from_to_(const value::qt::rgb32& from, bool& to);
-
-
- // bool -> rgb32.
- void from_to_(const bool& from, value::qt::rgb32& to);
-
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
namespace trait
{
template <>
@@ -350,14 +323,18 @@ namespace mln
/// \}
+ /// \internal Conversion: Conversion: #value::qt::rgb32 -> bool.
+ void from_to_(const rgb32& from, bool& to);
+
+ /// \internal Conversion: bool -> #value::qt::rgb32.
+ void from_to_(const bool& from, value::qt::rgb32& to);
+
} // end of namespace mln::value::qt
} // end of namespace mln::value
} // end of namespace mln
-
-
# ifndef MLN_INCLUDE_ONLY
namespace mln
@@ -752,45 +729,15 @@ namespace mln
return istr >> c.red() >> c.green() >> c.blue();
}
- } // end of namespace mln::value::qt
-
- } // end of namespace mln::value
-
-
- namespace convert
- {
-
- namespace over_load
- {
- // int_u -> qt::rgb32
- template <unsigned m>
- void
- from_to_(const value::int_u<m>& from, value::qt::rgb32& to)
- {
- mlc_bool(m <= 8)::check();
- to = value::qt::rgb32(from, from, from);
- }
+ // Conversions
-
- // hsl -> rgb8.
- template <typename H, typename S, typename L>
- void from_to_(const value::hsl_<H,S,L>& from, value::qt::rgb32& to)
- {
- value::rgb8 v = fun::v2v::f_hsl_to_rgb_3x8(from);
- to = v.to_equiv();
- }
-
-
- // qt::rgb32 -> bool
inline
- void from_to_(const value::qt::rgb32& from, bool& to)
+ void from_to_(const rgb32& from, bool& to)
{
to = ((from == literal::black) ? false : true);
}
-
- // bool -> qt::rgb32
inline
void from_to_(const bool& from, value::qt::rgb32& to)
{
@@ -800,10 +747,9 @@ namespace mln
to = literal::black;
}
+ } // end of namespace mln::value::qt
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ } // end of namespace mln::value
} // end of namespace mln
diff --git a/milena/mln/value/rgb.hh b/milena/mln/value/rgb.hh
index c9d2f53..1c812d7 100644
--- a/milena/mln/value/rgb.hh
+++ b/milena/mln/value/rgb.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008, 2009, 2010 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2010, 2012 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -30,7 +30,6 @@
# include <mln/value/ops.hh>
-# include <mln/fun/v2v/hsl_to_rgb.hh>
# include <mln/value/concept/vectorial.hh>
# include <mln/value/int_u.hh>
# include <mln/algebra/vec.hh>
@@ -46,28 +45,18 @@ namespace mln
{
// Forward declaration.
- namespace value { template <unsigned n> struct rgb; }
+ namespace value {
+ template <unsigned n> struct rgb;
+ template <typename H, typename S, typename L> class hsl_;
-
-
- namespace fun
- {
-
- namespace v2v
- {
-
- template <typename T_rgb>
- struct f_hsl_to_rgb_;
-
- typedef f_hsl_to_rgb_< value::rgb<8> > f_hsl_to_rgb_3x8_t;
-// typedef f_hsl_to_rgb_< value::rgb<16> > f_hsl_to_rgb_3x16_t;
-
- extern f_hsl_to_rgb_3x8_t f_hsl_to_rgb_3x8;
-// extern f_hsl_to_rgb_3x16_t f_hsl_to_rgb_3x16;
-
- }
-
- }
+ }
+ namespace fun {
+ namespace v2v {
+ template <typename T_hsl> struct f_rgb_to_hsl_;
+ typedef f_rgb_to_hsl_<value::hsl_<float, float, float> > f_rgb_to_hsl_f_t;
+ extern f_rgb_to_hsl_f_t f_rgb_to_hsl_f;
+ }
+ }
namespace literal
@@ -104,42 +93,6 @@ namespace mln
template <typename H, typename S, typename L> class hsl_;
}
-
- namespace convert
- {
-
- namespace over_load
- {
-
- // algebra::vec -> rgb.
- template <typename T, unsigned m>
- void from_to_(const algebra::vec<3,T>& from, value::rgb<m>& to_);
-
- // bool -> rgb.
- template <unsigned m>
- void from_to_(bool from, value::rgb<m>& to);
-
- // int_u -> rgb.
- template <unsigned m>
- void from_to_(const value::int_u<m>& from, value::rgb<m>& to);
-
- // hsl -> rgb8.
- template <typename H, typename S, typename L>
- void from_to_(const value::hsl_<H,S,L>&, value::rgb<8>& to);
-
-// // hsl -> rgb16.
-// template <typename H, typename S, typename L>
-// void from_to_(const value::hsl_<H,S,L>&, value::rgb<16>& to);
-
- // rgb -> bool.
- template <unsigned m>
- void from_to_(const value::rgb<m>& from, bool& to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
namespace trait
{
template < unsigned n >
@@ -395,14 +348,38 @@ namespace mln
operator/(const rgb<n>& lhs, const mln::value::scalar_<S>& s);
/// \}
+ } // end of namespace mln::value
+
+
+ // Conversions
+
+ namespace value
+ {
+
+ /// \internal Conversion: rgb -> bool.
+ template <unsigned m>
+ void from_to_(const value::rgb<m>& from, bool& to);
+
+ /// \internal Conversion: rgb to hsl_
+ void
+ from_to_(const rgb<16>& from, hsl_<float,float,float>& to);
+
+ /// \internal Conversion: rgb to hsl_
+ void
+ from_to_(const rgb<8>& from, hsl_<float,float,float>& to);
+
+ /// \internal Conversion: bool -> rgb.
+ template <unsigned m>
+ void from_to_(bool from, value::rgb<m>& to);
} // end of namespace mln::value
} // end of namespace mln
-// // Needed by from_to_.
-// # include <mln/fun/v2v/rgb_to_hsl.hh>
+// Used in from_to
+# include <mln/value/hsl.hh>
+# include <mln/fun/v2v/rgb_to_hsl.hh>
# ifndef MLN_INCLUDE_ONLY
@@ -755,75 +732,46 @@ namespace mln
return istr >> c.red() >> c.green() >> c.blue();
}
- } // end of namespace mln::value
+ // Conversions
- namespace convert
- {
-
- namespace over_load
+ template <unsigned m>
+ void
+ from_to_(const rgb<m>& from, bool& to)
{
+ to = (from.red() != 0 && from.green() != 0 && from.blue() != 0);
+ }
- // algebra::vec -> rgb.
- template <typename T, unsigned m>
- inline
- void
- from_to_(const algebra::vec<3,T>& from, value::rgb<m>& to)
- {
- algebra::vec<3, unsigned> tmp;
- for (unsigned i = 0; i < 3; ++i)
- tmp[i] = static_cast<unsigned>(from[i]); // FIXME: Use from_to_ instead of cast.
-
- to = value::rgb<m>(tmp);
- }
-
- // bool -> rgb.
- template <unsigned m>
- void
- from_to_(bool from, value::rgb<m>& to)
- {
- static literal::white_t* white_ = 0;
- static literal::black_t* black_ = 0;
- // We do not use literal::white (the object) so that we
- // do not introduce any coupling with the file where
- // literals are defined.
- if (from)
- to = *white_;
- else
- to = *black_;
- }
-
- template <unsigned m>
- void
- from_to_(const value::int_u<m>& from, value::rgb<m>& to)
- {
- to = value::rgb<m>(from, from, from);
- }
+ inline
+ void
+ from_to_(const rgb<16>& from, hsl_<float,float,float>& to)
+ {
+ to = fun::v2v::f_rgb_to_hsl_f(from);
+ }
- template <typename H, typename S, typename L>
- void
- from_to_(const value::hsl_<H,S,L>& from, value::rgb<8>& to)
- {
- to = fun::v2v::f_hsl_to_rgb_3x8(from);
- }
-
-// template <typename H, typename S, typename L>
-// void
-// from_to_(const value::hsl_<H,S,L>& from, value::rgb<16>& to)
-// {
-// to = fun::v2v::f_hsl_to_rgb_3x16(from);
-// }
-
- template <unsigned m>
- void
- from_to_(const value::rgb<m>& from, bool& to)
- {
- to = (from.red() != 0 && from.green() != 0 && from.blue() != 0);
- }
+ inline
+ void
+ from_to_(const rgb<8>& from, hsl_<float,float,float>& to)
+ {
+ to = fun::v2v::f_rgb_to_hsl_f(from);
+ }
- } // end of namespace mln::convert::over_load
+ template <unsigned m>
+ void
+ from_to_(bool from, mln::value::rgb<m>& to)
+ {
+ static mln::literal::white_t* white_ = 0;
+ static mln::literal::black_t* black_ = 0;
+ // We do not use literal::white (the object) so that we
+ // do not introduce any coupling with the file where
+ // literals are defined.
+ if (from)
+ to = *white_;
+ else
+ to = *black_;
+ }
- } // end of namespace mln::convert
+ } // end of namespace mln::value
} // end of namespace mln
diff --git a/milena/mln/win/multiple.hh b/milena/mln/win/multiple.hh
index 18b65c8..869ad7c 100644
--- a/milena/mln/win/multiple.hh
+++ b/milena/mln/win/multiple.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -32,7 +33,7 @@
///
/// \todo Implementation of the bkd_qiter (see FIXME).
-# include <mln/core/internal/window_base.hh>
+# include <mln/core/window.hh>
# include <mln/core/internal/site_relative_iterator_base.hh>
# include <mln/util/array.hh>
diff --git a/milena/mln/win/multiple_size.hh b/milena/mln/win/multiple_size.hh
index 765e83d..43861f3 100644
--- a/milena/mln/win/multiple_size.hh
+++ b/milena/mln/win/multiple_size.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008, 2009, 2011 EPITA Research and Development
+// Copyright (C) 2008, 2009, 2011, 2012 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -49,6 +49,7 @@ namespace mln
template <unsigned n, typename W, typename F> class multiple_size;
template <unsigned n, typename W, typename F> class multiple_size_qiter;
}
+ template <typename D> class window;
diff --git a/milena/tests/accu/site_set/rectangularity.cc b/milena/tests/accu/site_set/rectangularity.cc
index 8919494..7adbb60 100644
--- a/milena/tests/accu/site_set/rectangularity.cc
+++ b/milena/tests/accu/site_set/rectangularity.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2012 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -61,5 +62,6 @@ int main()
{
accu::site_set::rectangularity<point2d> a;
accu::site_set::rectangularity<point2d> b = exact(a);
+ (void) b;
}
}
diff --git a/milena/tests/core/other/graph_elt_neighborhood.cc b/milena/tests/core/other/graph_elt_neighborhood.cc
index 7206d92..356fc4a 100644
--- a/milena/tests/core/other/graph_elt_neighborhood.cc
+++ b/milena/tests/core/other/graph_elt_neighborhood.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -31,6 +31,7 @@
#include <mln/core/alias/point2d.hh>
#include <mln/core/site_set/p_vertices.hh>
+#include <mln/fun/i2v/array.hh>
#include <mln/util/graph.hh>
#include <mln/core/image/graph_elt_neighborhood.hh>
diff --git a/milena/tests/core/other/graph_elt_window.cc b/milena/tests/core/other/graph_elt_window.cc
index 6e56a89..15a74d3 100644
--- a/milena/tests/core/other/graph_elt_window.cc
+++ b/milena/tests/core/other/graph_elt_window.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -30,7 +31,7 @@
#include <mln/core/alias/point2d.hh>
#include <mln/core/image/graph_elt_window.hh>
#include <mln/core/site_set/p_vertices.hh>
-
+#include <mln/fun/i2v/array.hh>
#include <mln/util/graph.hh>
unsigned fwd_neighb[] = { 0, 2, 3 };
diff --git a/milena/tests/core/other/point_set_compatibility.cc b/milena/tests/core/other/point_set_compatibility.cc
index 095ca46..ac73ab6 100644
--- a/milena/tests/core/other/point_set_compatibility.cc
+++ b/milena/tests/core/other/point_set_compatibility.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -25,6 +26,7 @@
#include <mln/core/alias/point2d.hh>
+#include <mln/fun/i2v/array.hh>
#include <mln/core/site_set/p_array.hh>
#include <mln/core/site_set/p_set.hh>
#include <mln/core/site_set/p_vertices.hh>
diff --git a/milena/tests/draw/graph.cc b/milena/tests/draw/graph.cc
index c15ab57..845d318 100644
--- a/milena/tests/draw/graph.cc
+++ b/milena/tests/draw/graph.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -26,6 +27,7 @@
#include <vector>
#include <utility>
+#include <mln/fun/i2v/array.hh>
#include <mln/core/image/image2d.hh>
#include <mln/core/alias/point2d.hh>
#include <mln/debug/println.hh>
--
1.7.2.5
1
0
22 Jun '12
---
scribo/ChangeLog | 4 +
scribo/scribo/debug/logger.hh | 249 ++++++++++++++++++++++++++++++++++++++++-
2 files changed, 250 insertions(+), 3 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 69814de..1122e11 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,3 +1,7 @@
+2012-05-07 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ * scribo/debug/logger.hh: Improve log system.
+
2012-04-05 Guillaume Lazzara <z(a)lrde.epita.fr>
Remove useless targets in scribo/src/binarization.
diff --git a/scribo/scribo/debug/logger.hh b/scribo/scribo/debug/logger.hh
index f16dd89..5822cf3 100644
--- a/scribo/scribo/debug/logger.hh
+++ b/scribo/scribo/debug/logger.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2011 EPITA Research and Development Laboratory
+// Copyright (C) 2011, 2012 EPITA Research and Development Laboratory
// (LRDE)
//
// This file is part of Olena.
@@ -27,6 +27,8 @@
#ifndef SCRIBO_CORE_LOGGER_HH
# define SCRIBO_CORE_LOGGER_HH
+# include <iostream>
+# include <ctype.h>
# include <mln/core/concept/image.hh>
# include <mln/data/wrap.hh>
# include <mln/value/int_u8.hh>
@@ -34,6 +36,7 @@
# include <mln/io/pbm/save.hh>
# include <mln/io/pgm/save.hh>
# include <mln/io/ppm/save.hh>
+# include <mln/util/timer.hh>
namespace scribo
{
@@ -41,15 +44,48 @@ namespace scribo
namespace debug
{
+ /*! \brief Enum defining different level of image logging
+
+ According to the debug level set in #logger_ the image may
+ be saved or not.
+ */
enum Level
{
None = 0,
Special, // Reserved
Results,
AuxiliaryResults,
- All
+ All,
+ InvalidLevel // Reserved
};
+ /*! \brief Enum defining different modes of text logging
+
+ According to the verbose mode set in #logger_ the text may
+ be logged or not.
+ */
+ enum VerboseMode
+ {
+ Mute = 0,
+ UserDebug, // Reserved
+ Time,
+ Low,
+ Medium,
+ Full,
+ Invalid, // Reserved
+ };
+
+
+ /*! \brief returns the corresponding verboseMode from its name.
+
+ \internal
+ \warning Don't forget to update this function if a VerboseMode
+ value is added.
+ \endinternal
+ */
+ VerboseMode txt_to_verbose_mode(const std::string& name);
+
+
namespace internal
{
@@ -60,6 +96,22 @@ namespace scribo
public:
static logger_& instance();
+ /// Text Logging
+ /// @{
+ bool is_verbose() const;
+ bool is_at_verbose_mode(VerboseMode mode) const;
+
+ bool set_verbose_mode(VerboseMode mode);
+ VerboseMode verbose_mode() const;
+
+ void set_verbose_prefix(const std::string& prefix);
+
+ void log(VerboseMode mode, const std::string& text);
+ /// @}
+
+
+ /// Image Logging
+ /// @{
bool is_enabled() const;
bool is_at_level(Level level) const;
@@ -72,6 +124,37 @@ namespace scribo
template <typename I>
void log_image(Level dbg_level,
const Image<I>& ima, const char *name);
+ /// @}
+
+ /*! \brief Time Logging
+
+ This class provides two timers in order to performs
+ benchmarks inside a program.
+
+ Local time logging is meant to be used for benchmarking a
+ small portion of code, whereas global time logging is meant
+ to benchmark a whole program.
+
+ They can be used both at the same time.
+
+ Stopping time logging will output the computed time if
+ Verbose mode is higher or equal to #Time.
+ */
+ /// @{
+ void start_local_time_logging();
+ void stop_local_time_logging(const std::string& time_title);
+
+ void start_global_time_logging();
+ void stop_global_time_logging(const std::string& time_title);
+ /// @}
+
+
+ /*! \brief Quickly logs text.
+ It uses the default log mode to know if the text
+ */
+ template <typename V>
+ logger_& operator<<(const V&v);
+ logger_& operator<<(std::ostream& (*f)(std::ostream&));
private: // Methods
logger_();
@@ -110,6 +193,12 @@ namespace scribo
private: // Attributes
Level level_;
+ VerboseMode verbose_mode_;
+ std::string verbose_prefix_;
+ std::ostream& stream_;
+
+ mln::util::timer t_local_;
+ mln::util::timer t_global_;
};
} // end of namespace scribo::debug::internal
@@ -124,6 +213,14 @@ namespace scribo
namespace internal
{
+ std::string to_upper(const std::string& s)
+ {
+ std::string out(s);
+ for (size_t i = 0; i < s.size(); ++i)
+ out[i] = toupper(s[i]);
+ return out;
+ }
+
inline
logger_&
logger_::instance()
@@ -135,7 +232,10 @@ namespace scribo
inline
logger_::logger_()
- : level_(None)
+ : level_(None),
+ verbose_mode_(Mute),
+ stream_(std::cerr),
+ verbose_prefix_("LOG: ")
{
// Magick::InitializeMagick(0);
}
@@ -143,6 +243,7 @@ namespace scribo
inline
logger_::logger_(const logger_&)
+ : stream_(std::cerr)
{
abort();
}
@@ -150,6 +251,64 @@ namespace scribo
inline
bool
+ logger_::is_verbose() const
+ {
+ return verbose_mode_ > Mute;
+ }
+
+
+ inline
+ bool
+ logger_::is_at_verbose_mode(VerboseMode mode) const
+ {
+ return mode == verbose_mode_;
+ }
+
+
+ inline
+ bool
+ logger_::set_verbose_mode(VerboseMode mode)
+ {
+ if (mode != Invalid)
+ {
+ verbose_mode_ = mode;
+ return true;
+ }
+ return false;
+ }
+
+
+ inline
+ VerboseMode
+ logger_::verbose_mode() const
+ {
+ return verbose_mode_;
+ }
+
+
+ inline
+ void
+ logger_::set_verbose_prefix(const std::string& prefix)
+ {
+ verbose_prefix_ = prefix;
+ }
+
+
+ inline
+ void
+ logger_::log(VerboseMode mode, const std::string& text)
+ {
+# ifndef SCRIBO_NDEBUG
+ if (verbose_mode_ < mode)
+ return;
+
+ std::cerr << verbose_prefix_ << text << std::endl;
+# endif // ! SCRIBO_NDEBUG
+ }
+
+
+ inline
+ bool
logger_::is_enabled() const
{
return level_ != None;
@@ -212,6 +371,44 @@ namespace scribo
}
+ inline
+ void
+ logger_::start_local_time_logging()
+ {
+ t_local_.restart();
+ }
+
+
+ inline
+ void
+ logger_::stop_local_time_logging(const std::string& time_title)
+ {
+ t_local_.stop();
+ if (verbose_mode_ >= Time)
+ std::cerr << time_title << " " << t_local_ << "s" << std::endl;
+ }
+
+
+ inline
+ void
+ logger_::start_global_time_logging()
+ {
+ t_global_.restart();
+ }
+
+
+ inline
+ void
+ logger_::stop_global_time_logging(const std::string& time_title)
+ {
+ t_global_.stop();
+ if (verbose_mode_ >= Time)
+ std::cerr << time_title << " " << t_global_ << "s" << std::endl;
+ }
+
+
+ // Private dispatch
+
template <unsigned n, typename I>
void
logger_::log_image_dispatch(const value::int_u<n>&, const Image<I>& ima, const char *name)
@@ -273,6 +470,26 @@ namespace scribo
mln::debug::filename(name + ".pgm"));
}
+
+ template <typename V>
+ logger_&
+ logger_::operator<<(const V& v)
+ {
+ if (verbose_mode_ >= Low)
+ stream_ << v;
+ return *this;
+ }
+
+
+ logger_&
+ logger_::operator<<(std::ostream& (*f)(std::ostream&))
+ {
+ if (verbose_mode_ >= Low)
+ f(stream_);
+ return *this;
+ }
+
+
} // end of namespace scribo::debug::internal
@@ -284,6 +501,32 @@ namespace scribo
}
+ VerboseMode txt_to_verbose_mode(const std::string& name)
+ {
+ struct mode_name
+ {
+ const char *name;
+ VerboseMode mode;
+ };
+ static const mode_name mode[] = {
+ { "MUTE", Mute },
+ { "USERDEBUG", UserDebug },
+ { "TIME", Time },
+ { "LOW", Low },
+ { "MEDIUM", Medium },
+ { "FULL", Full },
+ { "INVALID", Invalid }
+ };
+
+ unsigned i;
+ std::string name_ = internal::to_upper(name);
+ for (i = 0; mode[i].mode != Invalid; ++i)
+ if (mode[i].name == name_)
+ break;
+
+ return mode[i].mode;
+ };
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace scribo::debug
--
1.7.2.5
1
0
olena-2.0-63-g9846847 mln/registration/icp.hh: Add a missing initialization.
by Guillaume Lazzara 22 Jun '12
by Guillaume Lazzara 22 Jun '12
22 Jun '12
---
milena/ChangeLog | 4 ++++
milena/mln/registration/icp.hh | 2 +-
2 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 306ac9d..c5146c0 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,9 @@
2012-05-07 Guillaume Lazzara <z(a)lrde.epita.fr>
+ * mln/registration/icp.hh: Add a missing initialization.
+
+2012-05-07 Guillaume Lazzara <z(a)lrde.epita.fr>
+
* mln/io/magick/save.hh: Add generic and fast implementations.
2012-05-07 Guillaume Lazzara <z(a)lrde.epita.fr>
diff --git a/milena/mln/registration/icp.hh b/milena/mln/registration/icp.hh
index 9448a2f..aa263f7 100644
--- a/milena/mln/registration/icp.hh
+++ b/milena/mln/registration/icp.hh
@@ -532,7 +532,7 @@ namespace mln
const vec3d_f& qT)
{
/// Spx: cross-covariance matrix.
- algebra::mat<3u,3u,float> Spx;
+ algebra::mat<3u,3u,float> Spx(literal::zero);
mln_piter(p_array<P>) p(P_);
// FIXME: could we use an accu?
--
1.7.2.5
1
0
olena-2.0-62-g13097b1 mln/io/magick/save.hh: Add generic and fast implementations
by Guillaume Lazzara 22 Jun '12
by Guillaume Lazzara 22 Jun '12
22 Jun '12
---
milena/ChangeLog | 4 +
milena/mln/io/magick/save.hh | 262 ++++++++++++++++++++++++++++++++++++++++--
2 files changed, 256 insertions(+), 10 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 4c844e5..306ac9d 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,9 @@
2012-05-07 Guillaume Lazzara <z(a)lrde.epita.fr>
+ * mln/io/magick/save.hh: Add generic and fast implementations.
+
+2012-05-07 Guillaume Lazzara <z(a)lrde.epita.fr>
+
* mln/draw/box_plain.hh: Fix unused variable warning.
2011-11-30 Guillaume Lazzara <z(a)lrde.epita.fr>
diff --git a/milena/mln/io/magick/save.hh b/milena/mln/io/magick/save.hh
index f592059..d3c4aa6 100644
--- a/milena/mln/io/magick/save.hh
+++ b/milena/mln/io/magick/save.hh
@@ -42,7 +42,7 @@
# include <mln/metal/equal.hh>
-# include <mln/core/image/image2d.hh>
+# include <mln/core/concept/image.hh>
# include <mln/value/int_u8.hh>
# include <mln/value/rgb8.hh>
@@ -138,15 +138,83 @@ namespace mln
- sizeof(value::rgb8::blue_t)));
}
- } // end of namespace mln::io::magick::impl
+ namespace generic
+ {
+
+ template <typename I>
+ void
+ paste_data(const Image<I>& ima_, Magick::Image& magick_ima)
+ {
+ trace::entering("io::magick::impl::generic::paste_data");
+
+ const I& ima = exact(ima_);
+
+ def::coord
+ ncols = geom::ncols(ima),
+ nrows = geom::nrows(ima);
+
+ // Ensure that there is only one reference to underlying image
+ // If this is not done, then image pixels will not be modified.
+ magick_ima.modifyImage();
+
+ Magick::Pixels view(magick_ima);
+ // As above, `ncols' is passed before `nrows'.
+ Magick::PixelPacket* pixels = view.get(0, 0, ncols, nrows);
+
+ mln_piter(I) p(ima.domain());
+ for_all(p)
+ *pixels++ = impl::get_color(ima(p));
+
+ view.sync();
+
+ trace::exiting("io::magick::impl::generic::paste_data");
+ }
+
+ template <typename I, typename J>
+ void
+ paste_data_opacity(const Image<I>& ima_,
+ const Image<J>& opacity_mask_,
+ Magick::Image& magick_ima)
+ {
+ trace::entering("io::magick::impl::generic::paste_data_opacity");
+
+ const I& ima = exact(ima_);
+ const J& opacity_mask = exact(opacity_mask_);
+
+ def::coord
+ ncols = geom::ncols(ima),
+ nrows = geom::nrows(ima);
+
+ // Ensure that there is only one reference to underlying image
+ // If this is not done, then image pixels will not be modified.
+ magick_ima.modifyImage();
+
+ Magick::Pixels view(magick_ima);
+ // As above, `ncols' is passed before `nrows'.
+ Magick::PixelPacket* pixels = view.get(0, 0, ncols, nrows);
+
+ mln_piter(I) p(ima.domain());
+ mln_piter(J) pm(opacity_mask.domain());
+
+ for_all_2(p, pm)
+ {
+ *pixels = impl::get_color(ima(p));
+ (*pixels).opacity = (opacity_mask(pm) ? 255 : 0);
+ ++pixels;
+ }
+
+ view.sync();
+
+ trace::exiting("io::magick::impl::generic::paste_data_opacity");
+ }
+
+ } // end of namespace mln::io::magick::impl::generic
- namespace internal
- {
template <typename I>
void
- paste_data(const Image<I>& ima_, Magick::Image& magick_ima)
+ paste_data_fastest(const Image<I>& ima_, Magick::Image& magick_ima)
{
const I& ima = exact(ima_);
@@ -177,11 +245,37 @@ namespace mln
view.sync();
}
+ template <typename I>
+ void
+ paste_data_fast(const Image<I>& ima_, Magick::Image& magick_ima)
+ {
+ const I& ima = exact(ima_);
+
+ def::coord
+ ncols = geom::ncols(ima),
+ nrows = geom::nrows(ima);
+
+ // Ensure that there is only one reference to underlying image
+ // If this is not done, then image pixels will not be modified.
+ magick_ima.modifyImage();
+
+ Magick::Pixels view(magick_ima);
+ // As above, `ncols' is passed before `nrows'.
+ Magick::PixelPacket* pixels = view.get(0, 0, ncols, nrows);
+
+
+ fwd_pixter2d<const I> pi(ima);
+ for_all(pi)
+ *pixels++ = impl::get_color(pi.val());
+
+ view.sync();
+ }
+
template <typename I, typename J>
void
- paste_data_opacity(const Image<I>& ima_,
- const Image<J>& opacity_mask_,
- Magick::Image& magick_ima)
+ paste_data_opacity_fastest(const Image<I>& ima_,
+ const Image<J>& opacity_mask_,
+ Magick::Image& magick_ima)
{
const I& ima = exact(ima_);
const J& opacity_mask = exact(opacity_mask_);
@@ -220,6 +314,154 @@ namespace mln
view.sync();
}
+
+
+
+ template <typename I, typename J>
+ void
+ paste_data_opacity_fast(const Image<I>& ima_,
+ const Image<J>& opacity_mask_,
+ Magick::Image& magick_ima)
+ {
+ const I& ima = exact(ima_);
+ const J& opacity_mask = exact(opacity_mask_);
+
+ def::coord
+ ncols = geom::ncols(ima),
+ nrows = geom::nrows(ima);
+
+ // Ensure that there is only one reference to underlying image
+ // If this is not done, then image pixels will not be modified.
+ magick_ima.modifyImage();
+
+ Magick::Pixels view(magick_ima);
+ // As above, `ncols' is passed before `nrows'.
+ Magick::PixelPacket* pixels = view.get(0, 0, ncols, nrows);
+
+ mln_pixter(const I) pi(ima);
+ mln_pixter(const J) pom(opacity_mask);
+
+ for_all_2(pi, pom)
+ {
+ *pixels = impl::get_color(pi.val());
+ (*pixels).opacity = (pom.val() ? 255 : 0);
+ ++pixels;
+ }
+
+ view.sync();
+ }
+
+ } // end of namespace mln::io::magick::impl
+
+
+ namespace internal
+ {
+
+ // paste_data_opacity
+
+ template <typename I, typename J>
+ void
+ paste_data_opacity_fast_dispatch(metal::false_, // No images are fast or fastest.
+ const Image<I>& ima,
+ const Image<J>& opacity_mask,
+ Magick::Image& magick_ima)
+ {
+ impl::generic::paste_data_opacity(ima, opacity_mask, magick_ima);
+ }
+
+ template <typename I, typename J>
+ void
+ paste_data_opacity_fast_dispatch(metal::true_, // Bost images are "fast" or one is fast and the other one is fastest.
+ const Image<I>& ima,
+ const Image<J>& opacity_mask,
+ Magick::Image& magick_ima)
+ {
+ impl::paste_data_opacity_fast(ima, opacity_mask, magick_ima);
+ }
+
+ template <typename I, typename J>
+ void
+ paste_data_opacity_fastest_dispatch(metal::false_, // At least one of the images is not "fastest".
+ const Image<I>& ima,
+ const Image<J>& opacity_mask,
+ Magick::Image& magick_ima)
+ {
+
+ enum { fast = mlc_and(mlc_is(mln_trait_image_value_storage(I), trait::image::value_storage::one_block),
+ mlc_is(mln_trait_image_value_storage(J), trait::image::value_storage::one_block))::value };
+ paste_data_opacity_fast_dispatch(metal::bool_<fast>(),
+ ima, opacity_mask, magick_ima);
+ }
+
+
+ template <typename I, typename J>
+ void
+ paste_data_opacity_fastest_dispatch(metal::true_, // Both images are "fastest".
+ const Image<I>& ima,
+ const Image<J>& opacity_mask,
+ Magick::Image& magick_ima)
+ {
+ impl::paste_data_opacity_fastest(ima, opacity_mask, magick_ima);
+ }
+
+ template <typename I, typename J>
+ void
+ paste_data_opacity_dispatch(const Image<I>& ima,
+ const Image<J>& opacity_mask,
+ Magick::Image& magick_ima)
+ {
+ enum { fastest = mlc_and(mlc_is(mln_trait_image_speed(I), trait::image::speed::fastest),
+ mlc_is(mln_trait_image_speed(J), trait::image::speed::fastest))::value };
+ paste_data_opacity_fastest_dispatch(metal::bool_<fastest>(),
+ ima, opacity_mask, magick_ima);
+ }
+
+
+ // paste_data
+
+
+ template <typename I>
+ void
+ paste_data_dispatch_fast(const mln::trait::image::value_storage::any&,
+ const Image<I>& ima, Magick::Image& magick_ima)
+ {
+ impl::generic::paste_data(ima, magick_ima);
+ }
+
+
+ template <typename I>
+ void
+ paste_data_dispatch_fast(const mln::trait::image::value_storage::one_block&,
+ const Image<I>& ima, Magick::Image& magick_ima)
+ {
+ impl::paste_data_fast(ima, magick_ima);
+ }
+
+
+ template <typename I>
+ void
+ paste_data_dispatch_fastest(const mln::trait::image::speed::any&,
+ const Image<I>& ima, Magick::Image& magick_ima)
+ {
+ paste_data_dispatch_fast(mln_trait_image_value_storage(I)(), ima, magick_ima);
+ }
+
+
+ template <typename I>
+ void
+ paste_data_dispatch_fastest(const mln::trait::image::speed::fastest&,
+ const Image<I>& ima, Magick::Image& magick_ima)
+ {
+ impl::paste_data_fastest(ima, magick_ima);
+ }
+
+ template <typename I>
+ void
+ paste_data_dispatch(const Image<I>& ima, Magick::Image& magick_ima)
+ {
+ paste_data_dispatch_fastest(mln_trait_image_speed(I)(), ima, magick_ima);
+ }
+
} // end of namespace mln::io::magick::internal
@@ -267,12 +509,12 @@ namespace mln
if (opacity_mask.is_valid())
{
magick_ima.type(Magick::TrueColorMatteType);
- internal::paste_data_opacity(ima, opacity_mask, magick_ima);
+ internal::paste_data_opacity_dispatch(ima, opacity_mask, magick_ima);
}
else
{
magick_ima.type(Magick::TrueColorType);
- internal::paste_data(ima, magick_ima);
+ internal::paste_data_dispatch(ima, magick_ima);
}
magick_ima.write(filename);
--
1.7.2.5
1
0
olena-2.0-61-gb7cf120 mln/draw/box_plain.hh: Fix unused variable warning.
by Guillaume Lazzara 22 Jun '12
by Guillaume Lazzara 22 Jun '12
22 Jun '12
---
milena/ChangeLog | 4 ++++
milena/mln/draw/box_plain.hh | 9 +++------
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 2454245..4c844e5 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,7 @@
+2012-05-07 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ * mln/draw/box_plain.hh: Fix unused variable warning.
+
2011-11-30 Guillaume Lazzara <z(a)lrde.epita.fr>
* mln/accu/math/sumpow.hh: New accumulator.
diff --git a/milena/mln/draw/box_plain.hh b/milena/mln/draw/box_plain.hh
index ec5b865..ed6ea9b 100644
--- a/milena/mln/draw/box_plain.hh
+++ b/milena/mln/draw/box_plain.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2012 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -73,11 +73,8 @@ namespace mln
const mln_value(I)& v)
{
mln_precondition(exact(ima).is_valid());
-
- mln_psite(I) pmin = exact(b).pmin();
- mln_psite(I) pmax = exact(b).pmax();
-
- mln_precondition(exact(ima).has(pmin) && exact(ima).has(pmax));
+ mln_precondition(exact(ima).has(exact(b).pmin())
+ && exact(ima).has(exact(b).pmax()));
data::fill((ima | b).rw(), v);
}
--
1.7.2.5
1
0
olena-2.0-60-g6bc3a11 Remove useless targets in scribo/src/binarization.
by Guillaume Lazzara 22 Jun '12
by Guillaume Lazzara 22 Jun '12
22 Jun '12
* scribo/src/binarization/Makefile.am: Remove targets.
* src/binarization/pgm_sauvola.cc,
* src/binarization/pgm_sauvola_ms.cc,
* src/binarization/pgm_sauvola_threshold_image.cc,
* src/binarization/ppm_sauvola.cc,
* src/binarization/ppm_sauvola_ms.cc,
* src/binarization/ppm_sauvola_ms_fg.cc,
* src/binarization/ppm_sauvola_ms_split.cc: Remove.
---
scribo/ChangeLog | 14 ++
scribo/src/binarization/Makefile.am | 20 +---
scribo/src/binarization/pgm_sauvola.cc | 80 ------------
scribo/src/binarization/pgm_sauvola_ms.cc | 111 ----------------
.../binarization/pgm_sauvola_threshold_image.cc | 78 ------------
scribo/src/binarization/ppm_sauvola.cc | 88 -------------
scribo/src/binarization/ppm_sauvola_ms.cc | 123 ------------------
scribo/src/binarization/ppm_sauvola_ms_fg.cc | 134 --------------------
scribo/src/binarization/ppm_sauvola_ms_split.cc | 128 -------------------
9 files changed, 16 insertions(+), 760 deletions(-)
delete mode 100644 scribo/src/binarization/pgm_sauvola.cc
delete mode 100644 scribo/src/binarization/pgm_sauvola_ms.cc
delete mode 100644 scribo/src/binarization/pgm_sauvola_threshold_image.cc
delete mode 100644 scribo/src/binarization/ppm_sauvola.cc
delete mode 100644 scribo/src/binarization/ppm_sauvola_ms.cc
delete mode 100644 scribo/src/binarization/ppm_sauvola_ms_fg.cc
delete mode 100644 scribo/src/binarization/ppm_sauvola_ms_split.cc
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 28de74b..69814de 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,19 @@
2012-04-05 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Remove useless targets in scribo/src/binarization.
+
+ * scribo/src/binarization/Makefile.am: Remove targets.
+
+ * src/binarization/pgm_sauvola.cc,
+ * src/binarization/pgm_sauvola_ms.cc,
+ * src/binarization/pgm_sauvola_threshold_image.cc,
+ * src/binarization/ppm_sauvola.cc,
+ * src/binarization/ppm_sauvola_ms.cc,
+ * src/binarization/ppm_sauvola_ms_fg.cc,
+ * src/binarization/ppm_sauvola_ms_split.cc: Remove.
+
+2012-04-05 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Cleanup text_in_picture_dual.
* src/Makefile.am: Update target name.
diff --git a/scribo/src/binarization/Makefile.am b/scribo/src/binarization/Makefile.am
index 567972a..a0a4378 100644
--- a/scribo/src/binarization/Makefile.am
+++ b/scribo/src/binarization/Makefile.am
@@ -1,4 +1,4 @@
-# Copyright (C) 2009, 2010, 2011 EPITA Research and Development
+# Copyright (C) 2009, 2010, 2011, 2012 EPITA Research and Development
# Laboratory (LRDE).
#
# This file is part of Olena.
@@ -18,25 +18,9 @@
include $(top_srcdir)/scribo/scribo.mk
noinst_PROGRAMS = \
- pgm_global_threshold_auto \
- pgm_sauvola \
- pgm_sauvola_ms \
- pgm_sauvola_threshold_image \
- ppm_sauvola \
- ppm_sauvola_ms_fg \
- ppm_sauvola_ms \
- ppm_sauvola_ms_split
-
+ pgm_global_threshold_auto
pgm_global_threshold_auto_SOURCES = pgm_global_threshold_auto.cc
-pgm_sauvola_SOURCES = pgm_sauvola.cc
-pgm_sauvola_ms_SOURCES = pgm_sauvola_ms.cc
-pgm_sauvola_threshold_image_SOURCES = pgm_sauvola_threshold_image.cc
-ppm_sauvola_SOURCES = ppm_sauvola.cc
-ppm_sauvola_ms_fg_SOURCES = ppm_sauvola_ms_fg.cc
-ppm_sauvola_ms_SOURCES = ppm_sauvola_ms.cc
-ppm_sauvola_ms_split_SOURCES = ppm_sauvola_ms_split.cc
-
if HAVE_MAGICKXX
diff --git a/scribo/src/binarization/pgm_sauvola.cc b/scribo/src/binarization/pgm_sauvola.cc
deleted file mode 100644
index 1052766..0000000
--- a/scribo/src/binarization/pgm_sauvola.cc
+++ /dev/null
@@ -1,80 +0,0 @@
-// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
-// (LRDE)
-//
-// This file is part of Olena.
-//
-// Olena is free software: you can redistribute it and/or modify it under
-// the terms of the GNU General Public License as published by the Free
-// Software Foundation, version 2 of the License.
-//
-// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
-//
-// As a special exception, you may use this file as part of a free
-// software project 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.
-
-#include <mln/io/pgm/load.hh>
-#include <mln/io/pbm/save.hh>
-
-#include <scribo/binarization/sauvola.hh>
-#include <scribo/debug/usage.hh>
-
-const char *args_desc[][2] =
-{
- { "input.pgm", "A gray level image." },
- { "output.pbm", "A binary image." },
- { "w", "Window size (default 101)." },
- { "k", "Sauvola's formulae parameter (default 0.34)." },
- {0, 0}
-};
-
-
-int main(int argc, char *argv[])
-{
- using namespace mln;
- using value::int_u8;
-
- if (argc != 5 && argc != 4 && argc != 3)
- return scribo::debug::usage(argv,
- "Binarization of a gray level image based on Sauvola's algorithm.",
- "input.pgm output.pbm <w> <k>",
- args_desc);
-
- trace::entering("main");
-
- unsigned w;
- if (argc == 4)
- w = atoi(argv[3]);
- else
- w = 101;
-
- double k;
- if (argc == 5)
- k = atof(argv[4]);
- else
- k = 0.34f;
-
- std::cout << "Using w=" << w << " and k=" << k << std::endl;
-
- image2d<int_u8> input;
- io::pgm::load(input, argv[1]);
-
- image2d<bool> out = scribo::binarization::sauvola(input, w, k);
-
-
- io::pbm::save(out, argv[2]);
-
-
- trace::exiting("main");
-}
diff --git a/scribo/src/binarization/pgm_sauvola_ms.cc b/scribo/src/binarization/pgm_sauvola_ms.cc
deleted file mode 100644
index 38ff2e6..0000000
--- a/scribo/src/binarization/pgm_sauvola_ms.cc
+++ /dev/null
@@ -1,111 +0,0 @@
-// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
-// (LRDE)
-//
-// This file is part of Olena.
-//
-// Olena is free software: you can redistribute it and/or modify it under
-// the terms of the GNU General Public License as published by the Free
-// Software Foundation, version 2 of the License.
-//
-// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
-//
-// As a special exception, you may use this file as part of a free
-// software project 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.
-
-#include <mln/core/image/image2d.hh>
-#include <mln/value/int_u8.hh>
-#include <mln/io/pgm/load.hh>
-#include <mln/io/pbm/save.hh>
-
-#include <scribo/binarization/sauvola_ms.hh>
-#include <scribo/debug/usage.hh>
-
-bool check_args(int argc, char * argv[])
-{
- if (argc < 3 || argc > 6)
- return false;
-
- if (argc >= 5)
- {
- int s = atoi(argv[4]);
-
- if (s < 1 || s > 3)
- {
- std::cout << "s must be set to 2 or 3."
- << std::endl;
- return false;
- }
- }
-
- return true;
-}
-
-
-const char *args_desc[][2] =
-{
- { "input.pgm", "A graylevel image." },
- { "out.pbm", "A binary image." },
- { "w", "Window size at scale 1. (default: 101)" },
- { "s", "First subsampling ratio (default: 3)." },
- { "k", "Sauvola's formuale parameter (default: 0.34)" },
- {0, 0}
-};
-
-
-
-
-int main(int argc, char *argv[])
-{
- using namespace mln;
- using namespace scribo;
-
- if (!check_args(argc, argv))
- return scribo::debug::usage(argv,
- "Multi-Scale Binarization of a color image based on Sauvola's algorithm.",
- "input.pgm output.pbm <w> <s> <k>",
- args_desc);
-
- trace::entering("main");
-
- // Window size
- unsigned w_1;
- if (argc >= 4)
- w_1 = atoi(argv[3]); // Scale 1
- else
- w_1 = 101u;
-
- // First subsampling scale.
- unsigned s;
- if (argc >= 5)
- s = atoi(argv[4]);
- else
- s = 3u;
-
- double k;
- if (argc >= 6)
- k = atof(argv[5]);
- else
- k = 0.34f;
-
- image2d<value::int_u8> input_1;
- io::pgm::load(input_1, argv[1]);
-
- image2d<bool>
- output = scribo::binarization::sauvola_ms(input_1, w_1, s, k);
-
- io::pbm::save(output, argv[2]);
-}
-
-
diff --git a/scribo/src/binarization/pgm_sauvola_threshold_image.cc b/scribo/src/binarization/pgm_sauvola_threshold_image.cc
deleted file mode 100644
index 69e2e15..0000000
--- a/scribo/src/binarization/pgm_sauvola_threshold_image.cc
+++ /dev/null
@@ -1,78 +0,0 @@
-// Copyright (C) 2010, 2011 EPITA Research and Development Laboratory
-// (LRDE)
-//
-// This file is part of Olena.
-//
-// Olena is free software: you can redistribute it and/or modify it under
-// the terms of the GNU General Public License as published by the Free
-// Software Foundation, version 2 of the License.
-//
-// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
-//
-// As a special exception, you may use this file as part of a free
-// software project 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.
-
-#include <mln/io/pgm/all.hh>
-
-#include <scribo/binarization/sauvola_threshold.hh>
-#include <scribo/debug/usage.hh>
-
-const char *args_desc[][2] =
-{
- { "input.pgm", "A graylevel image." },
- { "output.pgm", "A threshold image." },
- { "w", "Window size (default 101)." },
- { "k", "Sauvola's formulae parameter (default 0.34)." },
- {0, 0}
-};
-
-
-int main(int argc, char *argv[])
-{
- using namespace mln;
-
- if (argc != 5 && argc != 4 && argc != 3)
- return scribo::debug::usage(argv,
- "Compute a threshold image based on Sauvola's algorithm.",
- "input.pgm output.pgm <w> <k>",
- args_desc);
-
- trace::entering("main");
-
- unsigned w;
- if (argc >= 4)
- w = atoi(argv[3]);
- else
- w = 101;
-
- double k;
- if (argc >= 5)
- k = atof(argv[4]);
- else
- k = 0.34f;
-
- std::cout << "Using w=" << w << " and k=" << k << std::endl;
-
- image2d<value::int_u8> input;
- io::pgm::load(input, argv[1]);
-
- image2d<value::int_u8> out = scribo::binarization::sauvola_threshold(input, w, k);
-
-
- io::pgm::save(out, argv[2]);
-
-
- trace::exiting("main");
-}
diff --git a/scribo/src/binarization/ppm_sauvola.cc b/scribo/src/binarization/ppm_sauvola.cc
deleted file mode 100644
index 4732a02..0000000
--- a/scribo/src/binarization/ppm_sauvola.cc
+++ /dev/null
@@ -1,88 +0,0 @@
-// Copyright (C) 2009, 2010, 2011 EPITA Research and Development
-// Laboratory (LRDE)
-//
-// This file is part of Olena.
-//
-// Olena is free software: you can redistribute it and/or modify it under
-// the terms of the GNU General Public License as published by the Free
-// Software Foundation, version 2 of the License.
-//
-// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
-//
-// As a special exception, you may use this file as part of a free
-// software project 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.
-
-#include <mln/io/ppm/load.hh>
-#include <mln/io/pbm/save.hh>
-#include <mln/data/transform.hh>
-#include <mln/fun/v2v/rgb_to_luma.hh>
-
-#include <scribo/binarization/sauvola.hh>
-#include <scribo/debug/usage.hh>
-
-const char *args_desc[][2] =
-{
- { "input.ppm", "A color image." },
- { "output.pbm", "A binary image." },
- { "w", "Window size (default 101)." },
- { "k", "Sauvola's formulae parameter (default 0.34)." },
- {0, 0}
-};
-
-
-int main(int argc, char *argv[])
-{
- using namespace mln;
-
- if (argc != 5 && argc != 4 && argc != 3)
- return scribo::debug::usage(argv,
- "Binarization of a gray level image based on Sauvola's algorithm.",
- "input.ppm output.pbm <w> <k>",
- args_desc);
-
- trace::entering("main");
-
- unsigned w;
- if (argc == 4)
- w = atoi(argv[3]);
- else
- w = 101;
-
- double k;
- if (argc == 5)
- k = atof(argv[4]);
- else
- k = 0.34f;
-
- std::cout << "Using w=" << w << " and k=" << k << std::endl;
-
- // Load
- image2d<value::rgb8> input;
- io::ppm::load(input, argv[1]);
-
- // Convert to Gray level image.
- image2d<value::int_u8>
- input_gl = data::transform(input,
- mln::fun::v2v::rgb_to_luma<value::int_u8>());
-
- // Binarize
- image2d<bool> out = scribo::binarization::sauvola(input_gl, w, k);
-
-
- io::pbm::save(out, argv[2]);
-
-
- trace::exiting("main");
-}
diff --git a/scribo/src/binarization/ppm_sauvola_ms.cc b/scribo/src/binarization/ppm_sauvola_ms.cc
deleted file mode 100644
index cff28f9..0000000
--- a/scribo/src/binarization/ppm_sauvola_ms.cc
+++ /dev/null
@@ -1,123 +0,0 @@
-// Copyright (C) 2009, 2010, 2011 EPITA Research and Development
-// Laboratory (LRDE)
-//
-// This file is part of Olena.
-//
-// Olena is free software: you can redistribute it and/or modify it under
-// the terms of the GNU General Public License as published by the Free
-// Software Foundation, version 2 of the License.
-//
-// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
-//
-// As a special exception, you may use this file as part of a free
-// software project 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.
-
-#include <mln/core/image/image2d.hh>
-#include <mln/value/int_u8.hh>
-#include <mln/io/ppm/load.hh>
-#include <mln/io/pbm/save.hh>
-#include <mln/data/transform.hh>
-#include <mln/fun/v2v/rgb_to_luma.hh>
-
-#include <scribo/binarization/sauvola_ms.hh>
-#include <scribo/debug/usage.hh>
-
-bool check_args(int argc, char * argv[])
-{
- if (argc < 3 || argc > 6)
- return false;
-
- if (argc >= 5)
- {
- int s = atoi(argv[4]);
-
- if (s < 1 || s > 3)
- {
- std::cout << "s must be set to 2 or 3."
- << std::endl;
- return false;
- }
- }
-
- return true;
-}
-
-
-const char *args_desc[][2] =
-{
- { "input.ppm", "A color image." },
- { "out.pbm", "A binary image." },
- { "w", "Window size at scale 1. (default: 101)" },
- { "s", "First subsampling ratio (default: 3)." },
- { "k", "Sauvola's formuale parameter (default: 0.34)" },
- {0, 0}
-};
-
-
-
-
-int main(int argc, char *argv[])
-{
- using namespace mln;
- using namespace scribo;
-
- if (!check_args(argc, argv))
- return scribo::debug::usage(argv,
- "Multi-Scale Binarization of a color image based on Sauvola's algorithm.",
- "input.ppm output.pbm <w> <s> <k>",
- args_desc);
-
- trace::entering("main");
-
- // Window size
- unsigned w_1;
- if (argc >= 4)
- w_1 = atoi(argv[3]); // Scale 1
- else
- w_1 = 101u;
-
- // First subsampling scale.
- unsigned s;
- if (argc >= 5)
- s = atoi(argv[4]);
- else
- s = 3u;
-
- double k;
- if (argc >= 6)
- k = atof(argv[5]);
- else
- k = 0.34f;
-
- std::cout << "Using w_1=" << w_1 << " - s=" << s
- << " - k=" << k << std::endl;
-
- // Load
- image2d<value::rgb8> input_1;
- io::ppm::load(input_1, argv[1]);
-
- // Convert to Gray level image.
- image2d<value::int_u8>
- input_1_gl = data::transform(input_1,
- mln::fun::v2v::rgb_to_luma<value::int_u8>());
-
- // Binarize
- image2d<bool>
- output = scribo::binarization::sauvola_ms(input_1_gl, w_1, s, k);
-
- io::pbm::save(output, argv[2]);
-}
-
-
diff --git a/scribo/src/binarization/ppm_sauvola_ms_fg.cc b/scribo/src/binarization/ppm_sauvola_ms_fg.cc
deleted file mode 100644
index a17ce9f..0000000
--- a/scribo/src/binarization/ppm_sauvola_ms_fg.cc
+++ /dev/null
@@ -1,134 +0,0 @@
-// Copyright (C) 2009, 2010, 2011 EPITA Research and Development
-// Laboratory (LRDE)
-//
-// This file is part of Olena.
-//
-// Olena is free software: you can redistribute it and/or modify it under
-// the terms of the GNU General Public License as published by the Free
-// Software Foundation, version 2 of the License.
-//
-// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
-//
-// As a special exception, you may use this file as part of a free
-// software project 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
-
-#include <mln/core/image/image2d.hh>
-#include <mln/value/rgb8.hh>
-#include <mln/io/ppm/load.hh>
-#include <mln/io/pbm/save.hh>
-#include <mln/data/transform.hh>
-#include <mln/fun/v2v/rgb_to_luma.hh>
-
-#include <scribo/binarization/sauvola_ms.hh>
-#include <scribo/preprocessing/split_bg_fg.hh>
-#include <scribo/debug/usage.hh>
-
-bool check_args(int argc, char * argv[])
-{
- if (argc < 3 || argc > 7)
- return false;
-
- if (argc >= 6)
- {
- int s = atoi(argv[5]);
-
- if (s < 2 || s > 3)
- {
- std::cout << "s must be set to 2 or 3."
- << std::endl;
- return false;
- }
- }
-
- return true;
-}
-
-
-const char *args_desc[][2] =
-{
- { "input.ppm", "A color image." },
- { "output.pbm", "A binary image." },
- { "lambda", "Lambda used to split bg/fg." },
- { "w", "Window size at scale 1. (default: 101)" },
- { "s", "First subsampling ratio. (default: 3)" },
- { "k", "Sauvola's formula parameter. (default: 0.34)" },
- {0, 0}
-};
-
-
-
-
-int main(int argc, char *argv[])
-{
- using namespace mln;
- using namespace scribo;
-
- if (!check_args(argc, argv))
- return scribo::debug::usage(argv,
- "Multi-Scale Binarization of a color image based on Sauvola's algorithm. Performs a binarization on each component of the color image and merges the results.",
- "input.ppm output.pbm lambda <w> <s> <k>",
- args_desc);
-
- trace::entering("main");
-
- unsigned lambda = atoi(argv[3]);
-
- // Window size
- unsigned w_1;
- if (argc >= 5)
- w_1 = atoi(argv[4]); // Scale 1
- else
- w_1 = 101u;
-
- // First subsampling scale.
- unsigned s;
- if (argc >= 6)
- s = atoi(argv[5]);
- else
- s = 3u;
-
- double k;
- if (argc >= 7)
- k = atof(argv[6]);
- else
- k = 0.34f;
-
- std::cout << "Using w_1=" << w_1 << " - s=" << s
- << " - k=" << k << std::endl;
-
- // Load
- image2d<value::rgb8> input_1;
- io::ppm::load(input_1, argv[1]);
-
-
- // Split foreground/background
- image2d<value::rgb8>
- fg = scribo::preprocessing::split_bg_fg(input_1, lambda, 32).second();
-
-
- // Convert to Gray level image.
- image2d<value::int_u8>
- fg_gl = data::transform(fg, mln::fun::v2v::rgb_to_luma<value::int_u8>());
-
- // Binarize
- image2d<bool>
- output = scribo::binarization::sauvola_ms(fg_gl, w_1, s, k);
-
- io::pbm::save(output, argv[2]);
-}
-
-
diff --git a/scribo/src/binarization/ppm_sauvola_ms_split.cc b/scribo/src/binarization/ppm_sauvola_ms_split.cc
deleted file mode 100644
index 92a0817..0000000
--- a/scribo/src/binarization/ppm_sauvola_ms_split.cc
+++ /dev/null
@@ -1,128 +0,0 @@
-// Copyright (C) 2009, 2010, 2011 EPITA Research and Development
-// Laboratory (LRDE)
-//
-// This file is part of Olena.
-//
-// Olena is free software: you can redistribute it and/or modify it under
-// the terms of the GNU General Public License as published by the Free
-// Software Foundation, version 2 of the License.
-//
-// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
-//
-// As a special exception, you may use this file as part of a free
-// software project 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.
-
-#include <mln/core/image/image2d.hh>
-#include <mln/value/rgb8.hh>
-#include <mln/io/ppm/load.hh>
-#include <mln/io/pbm/save.hh>
-#include <mln/data/transform.hh>
-
-#include <scribo/binarization/sauvola_ms_split.hh>
-#include <scribo/debug/usage.hh>
-
-bool check_args(int argc, char * argv[])
-{
- if (argc < 3 || argc > 7)
- return false;
-
- if (argc >= 5)
- {
- int s = atoi(argv[4]);
-
- if (s < 1 || s > 3)
- {
- std::cout << "s must be set to 2 or 3."
- << std::endl;
- return false;
- }
- }
-
- return true;
-}
-
-
-const char *args_desc[][2] =
-{
- { "input.ppm", "A color image." },
- { "output.pbm", "A binary image." },
- { "w", "Window size at scale 1. (default: 101)" },
- { "s", "First subsampling ratio (default: 3)." },
- { "min_ntrue", "The number of components in which a site must be set to 'True' in order to be set to 'True' in the output (Possible values: 1, 2, 3). (default: 2)" },
- { "K", "Sauvola's formula parameter (default: 0.34)." },
- {0, 0}
-};
-
-
-
-
-int main(int argc, char *argv[])
-{
- using namespace mln;
- using namespace scribo;
-
- if (!check_args(argc, argv))
- return scribo::debug::usage(argv,
- "Multi-Scale Binarization of a color image based on Sauvola's algorithm. Performs a binarization on each component of the color image and merges the results.",
- "input.ppm output.pbm <w> <s> <min_ntrue> <K>",
- args_desc);
-
- trace::entering("main");
-
- // Window size
- unsigned w_1;
- if (argc >= 4)
- w_1 = atoi(argv[3]); // Scale 1
- else
- w_1 = 101u;
-
- // First subsampling scale.
- unsigned s;
- if (argc >= 5)
- s = atoi(argv[4]);
- else
- s = 3u;
-
- // min_ntrue
- unsigned min_ntrue;
- if (argc >= 6)
- min_ntrue = atoi(argv[5]);
- else
- min_ntrue = 2;
-
-
- double k;
- if (argc >= 7)
- k = atof(argv[6]);
- else
- k = 0.34f;
-
-
- // Load
- image2d<value::rgb8> input_1;
- io::ppm::load(input_1, argv[1]);
-
- std::cout << "Using w=" << w_1 << " - s=" << s
- << " - min_ntrue=" << min_ntrue << " - k=" << k << std::endl;
-
- // Binarize
- image2d<bool>
- output = scribo::binarization::sauvola_ms_split(input_1, w_1, s,
- min_ntrue, k);
-
- io::pbm::save(output, argv[2]);
-}
-
-
--
1.7.2.5
1
0
* src/Makefile.am: Update target name.
* src/text_in_picture_neg.cc: Rename as...
* src/text_in_picture_dual.cc: ... this. Use option parser.
---
scribo/ChangeLog | 9 +
scribo/src/Makefile.am | 14 +-
...{text_in_picture.cc => text_in_picture_dual.cc} | 52 ++++--
scribo/src/text_in_picture_neg.cc | 197 --------------------
4 files changed, 56 insertions(+), 216 deletions(-)
copy scribo/src/{text_in_picture.cc => text_in_picture_dual.cc} (73%)
delete mode 100644 scribo/src/text_in_picture_neg.cc
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 3dbe7db..28de74b 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,3 +1,12 @@
+2012-04-05 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Cleanup text_in_picture_dual.
+
+ * src/Makefile.am: Update target name.
+
+ * src/text_in_picture_neg.cc: Rename as...
+ * src/text_in_picture_dual.cc: ... this. Use option parser.
+
2012-04-02 Guillaume Lazzara <z(a)lrde.epita.fr>
Make unskew an option in content_in_doc.
diff --git a/scribo/src/Makefile.am b/scribo/src/Makefile.am
index 08dc3ce..f0b1298 100644
--- a/scribo/src/Makefile.am
+++ b/scribo/src/Makefile.am
@@ -73,13 +73,13 @@ endif HAVE_TESSERACT
$(MAGICKXX_LDFLAGS)
- utilexec_PROGRAMS += text_in_picture_neg
- text_in_picture_neg_SOURCES = text_in_picture_neg.cc
- text_in_picture_neg_CPPFLAGS = $(AM_CPPFLAGS) \
- $(MAGICKXX_CPPFLAGS)
- text_in_picture_neg_LDFLAGS = $(AM_LDFLAGS) \
- -lpthread \
- $(MAGICKXX_LDFLAGS)
+ utilexec_PROGRAMS += text_in_picture_dual
+ text_in_picture_dual_SOURCES = text_in_picture_dual.cc
+ text_in_picture_dual_CPPFLAGS = $(AM_CPPFLAGS) \
+ $(MAGICKXX_CPPFLAGS)
+ text_in_picture_dual_LDFLAGS = $(AM_LDFLAGS) \
+ -lpthread \
+ $(MAGICKXX_LDFLAGS)
if HAVE_TESSERACT
diff --git a/scribo/src/text_in_picture.cc b/scribo/src/text_in_picture_dual.cc
similarity index 73%
copy from scribo/src/text_in_picture.cc
copy to scribo/src/text_in_picture_dual.cc
index d38d756..3eb9433 100644
--- a/scribo/src/text_in_picture.cc
+++ b/scribo/src/text_in_picture_dual.cc
@@ -1,5 +1,5 @@
-// Copyright (C) 2009, 2010, 2011 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2010, 2011 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -33,6 +33,8 @@
#include <scribo/debug/option_parser.hh>
#include <scribo/debug/logger.hh>
+#include <mln/world/rgb/invert.hh>
+#include <scribo/primitive/merge/components.hh>
static const scribo::debug::arg_data arg_desc[] =
{
@@ -65,10 +67,10 @@ static const scribo::debug::opt_data opt_desc[] =
};
-
int main(int argc, char* argv[])
{
using namespace scribo;
+ using namespace scribo::primitive;
using namespace mln;
scribo::debug::option_parser options(arg_desc, toggle_desc, opt_desc);
@@ -82,12 +84,13 @@ int main(int argc, char* argv[])
scribo::debug::logger().set_level(scribo::debug::All);
}
+
trace::entering("main");
Magick::InitializeMagick(*argv);
image2d<value::rgb8> input_rgb;
- io::magick::load(input_rgb, options.arg("input.*"));
+ io::magick::load(input_rgb, argv[1]);
bool verbose = options.is_set("verbose");
unsigned max_dim_size = atoi(options.opt_value("max-dim-size").c_str());
@@ -101,18 +104,43 @@ int main(int argc, char* argv[])
<< " - multi_scale_bin = " << multi_scale_bin
<< " - lambda = " << lambda << std::endl;
- component_set<image2d<scribo::def::lbl_type> >
- comps = toolchain::text_in_picture(input_rgb,
- fg_extraction, multi_scale_bin,
+
+ typedef image2d<scribo::def::lbl_type> L;
+ component_set<L>
+ comps = toolchain::text_in_picture(input_rgb, fg_extraction, multi_scale_bin,
max_dim_size, lambda, verbose);
+ typedef image2d<scribo::def::lbl_type> L;
+ component_set<L>
+ comps_neg = toolchain::text_in_picture(world::rgb::invert(input_rgb),
+ fg_extraction, multi_scale_bin,
+ max_dim_size, lambda, verbose);
+
+
+ component_set<L> merged_comps = primitive::merge::components(comps, comps_neg);
+
+
io::ppm::save(mln::labeling::colorize(value::rgb8(),
- comps.labeled_image(),
- comps.nelements()),
+ merged_comps.labeled_image(),
+ merged_comps.nelements()),
options.arg("output.ppm"));
-
- trace::exiting("main");
- return comps.nelements() != 0;
+# ifndef SCRIBO_NDEBUG
+ if (scribo::debug::logger().is_enabled())
+ {
+ scribo::debug::logger().log_image(scribo::debug::Results,
+ scribo::debug::highlight_text_area(input_rgb,
+ merged_comps),
+ "input_with_bboxes.ppm");
+ scribo::debug::logger().log_image(scribo::debug::Results,
+ scribo::debug::text_areas_image(input_rgb,
+ merged_comps),
+ "out_text.ppm");
+ }
+# endif // ! SCRIBO_NDEBUG
+
+ std::cout << "# objects = " << merged_comps.nelements() << std::endl;
+
+ return merged_comps.nelements() != 0;
}
diff --git a/scribo/src/text_in_picture_neg.cc b/scribo/src/text_in_picture_neg.cc
deleted file mode 100644
index dcd6857..0000000
--- a/scribo/src/text_in_picture_neg.cc
+++ /dev/null
@@ -1,197 +0,0 @@
-// Copyright (C) 2010, 2011 EPITA Research and Development Laboratory
-// (LRDE)
-//
-// This file is part of Olena.
-//
-// Olena is free software: you can redistribute it and/or modify it under
-// the terms of the GNU General Public License as published by the Free
-// Software Foundation, version 2 of the License.
-//
-// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
-//
-// As a special exception, you may use this file as part of a free
-// software project 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.
-
-#include <libgen.h>
-#include <iostream>
-
-#include <mln/core/image/image2d.hh>
-#include <mln/core/image/imorph/tr_image.hh>
-#include <mln/core/alias/neighb2d.hh>
-
-#include <mln/labeling/colorize.hh>
-
-#include <mln/data/stretch.hh>
-
-#include <mln/io/pbm/all.hh>
-#include <mln/io/ppm/save.hh>
-#include <mln/io/magick/all.hh>
-
-#include <mln/arith/revert.hh>
-
-#include <mln/math/min.hh>
-
-#include <mln/logical/not.hh>
-
-#include <mln/literal/colors.hh>
-#include <mln/value/rgb8.hh>
-
-#include <mln/data/wrap.hh>
-
-#include <mln/draw/box.hh>
-
-#include <mln/geom/translate.hh>
-
-#include <mln/subsampling/antialiased.hh>
-
-#include <mln/world/rgb/invert.hh>
-
-#include <scribo/draw/bounding_boxes.hh>
-#include <scribo/draw/groups_bboxes.hh>
-
-#include <scribo/binarization/sauvola_ms.hh>
-#include <scribo/binarization/sauvola.hh>
-
-#include <scribo/primitive/extract/components.hh>
-
-#include <scribo/primitive/link/merge_double_link.hh>
-#include <scribo/primitive/link/with_single_left_link.hh>
-#include <scribo/primitive/link/with_single_right_link.hh>
-
-#include <scribo/primitive/group/apply.hh>
-#include <scribo/primitive/group/from_double_link.hh>
-#include <scribo/primitive/group/from_single_link.hh>
-
-#include <scribo/primitive/regroup/from_single_left_link.hh>
-// #include <scribo/primitive/regroup/from_single_left_link_wrt_h_ratio.hh>
-
-#include <scribo/filter/object_groups_with_holes.hh>
-
-#include <scribo/filter/object_links_bbox_h_ratio.hh>
-#include <scribo/filter/object_links_bbox_overlap.hh>
-
-#include <scribo/filter/common/objects_photo.hh>
-
-#include <scribo/filter/object_groups_small.hh>
-
-#include <scribo/debug/highlight_text_area.hh>
-#include <scribo/debug/text_areas_image.hh>
-
-#include <scribo/debug/decision_image.hh>
-
-#include <scribo/debug/usage.hh>
-
-#include <scribo/preprocessing/split_bg_fg.hh>
-
-#include <scribo/make/debug_filename.hh>
-
-#include <scribo/toolchain/text_in_picture.hh>
-
-#include <scribo/primitive/merge/components.hh>
-
-#include <mln/util/timer.hh>
-#include <mln/core/var.hh>
-
-const char *args_desc[][2] =
-{
- { "input.*", "A color image." },
- { "ouput.ppm", "A color image where the text is highlighted." },
- { "debug_output_dir", "Directory were debug images will be saved" },
- { "lambda", "Lambda value used for foreground extraction" },
- {0, 0}
-};
-
-
-
-int main(int argc, char* argv[])
-{
- using namespace scribo;
- using namespace scribo::primitive;
- using namespace mln;
-
- if (argc < 3 || argc > 8)
- return scribo::debug::usage(argv,
- "Find text in a photo.\n\n"
- "Common usage: ./text_in_photo_fast input.*"
- " output.ppm 1 1",
- "input.ppm output.ppm <bg/fg enabled>"
- " <sauvola_ms enabled> "
- "[debug_output_dir] [max_dim_size] [lambda]",
- args_desc);
-
- char *out_base_dir = 0;
- if (argc > 5)
- out_base_dir = argv[5];
-
- trace::entering("main");
-
- Magick::InitializeMagick(*argv);
-
- image2d<value::rgb8> input_rgb;
- io::magick::load(input_rgb, argv[1]);
-
- unsigned max_dim_size = 0;
- if (argc >= 7)
- max_dim_size = atoi(argv[6]);
-
-
- unsigned lambda = 0;
- if (argc == 8)
- lambda = atoi(argv[7]);
-
- bool bg_removal = false;
- if (argc > 3 && atoi(argv[3]) != 0)
- bg_removal = true;
-
- bool multi_scale_bin = false;
- if (argc > 4 && atoi(argv[4]) != 0)
- multi_scale_bin = true;
-
-
- typedef image2d<scribo::def::lbl_type> L;
- component_set<L>
- comps = toolchain::text_in_picture(input_rgb, bg_removal, multi_scale_bin,
- max_dim_size, lambda, out_base_dir);
-
-
- typedef image2d<scribo::def::lbl_type> L;
- component_set<L>
- comps_neg = toolchain::text_in_picture(world::rgb::invert(input_rgb),
- bg_removal,
- multi_scale_bin,
- max_dim_size, lambda, out_base_dir);
-
-
- component_set<L> merged_comps = primitive::merge::components(comps, comps_neg);
-
-
-
- io::ppm::save(mln::labeling::colorize(value::rgb8(),
- merged_comps.labeled_image(),
- merged_comps.nelements()),
- argv[2]);
-
- if (out_base_dir)
- {
- io::ppm::save(scribo::debug::highlight_text_area(input_rgb, merged_comps),
- std::string(out_base_dir) + "_input_with_bboxes.ppm");
- io::ppm::save(scribo::debug::text_areas_image(input_rgb, merged_comps),
- std::string(out_base_dir) + "_out_text.ppm");
- }
-
- std::cout << "# objects = " << merged_comps.nelements() << std::endl;
-
- return merged_comps.nelements() != 0;
-}
--
1.7.2.5
1
0
22 Jun '12
* scribo/toolchain/text_in_doc_preprocess.hh,
* src/content_in_doc.cc: Make unskew an option.
---
scribo/ChangeLog | 7 +++++++
scribo/scribo/toolchain/text_in_doc_preprocess.hh | 13 +++++++------
scribo/src/content_in_doc.cc | 4 +++-
3 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index df9d036..3dbe7db 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,3 +1,10 @@
+2012-04-02 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Make unskew an option in content_in_doc.
+
+ * scribo/toolchain/text_in_doc_preprocess.hh,
+ * src/content_in_doc.cc: Make unskew an option.
+
2011-12-12 Guillaume Lazzara <z(a)lrde.epita.fr>
* scribo/subsampling/integral_single_image.hh: Fix forward
diff --git a/scribo/scribo/toolchain/text_in_doc_preprocess.hh b/scribo/scribo/toolchain/text_in_doc_preprocess.hh
index 0a99487..efa03dd 100644
--- a/scribo/scribo/toolchain/text_in_doc_preprocess.hh
+++ b/scribo/scribo/toolchain/text_in_doc_preprocess.hh
@@ -65,7 +65,7 @@ namespace scribo
template <typename I>
mln_ch_value(I,bool)
text_in_doc_preprocess(const Image<I>& input, bool enable_fg_bg,
- unsigned lambda, double K,
+ unsigned lambda, double K, bool enable_deskew,
bool verbose = false);
/*! \overload
@@ -108,7 +108,7 @@ namespace scribo
mln_ch_value(I,bool)
text_in_doc_preprocess(const Image<I>& input, unsigned lambda,
double K, bool enable_fg_bg, Image<I>& fg,
- bool verbose = false);
+ bool enable_deskew, bool verbose = false);
# ifndef MLN_INCLUDE_ONLY
@@ -126,7 +126,7 @@ namespace scribo
template <typename I>
mln_ch_value(I,bool)
text_in_doc_preprocess(const Image<I>& input_, bool enable_fg_bg,
- unsigned lambda, double K,
+ unsigned lambda, double K, bool enable_deskew = false,
bool verbose = false)
{
const I& input = exact(input_);
@@ -138,7 +138,7 @@ namespace scribo
mln_concrete(I) tmp_fg;
mln_ch_value(I,bool)
output = text_in_doc_preprocess(input, lambda, K,
- enable_fg_bg, tmp_fg, verbose);
+ enable_fg_bg, tmp_fg, enable_deskew, verbose);
return output;
}
@@ -149,7 +149,7 @@ namespace scribo
bool verbose = false)
{
I tmp;
- return text_in_doc_preprocess(input, lambda, 0.34, true, tmp, verbose);
+ return text_in_doc_preprocess(input, lambda, 0.34, true, tmp, false, verbose);
}
@@ -157,7 +157,7 @@ namespace scribo
mln_ch_value(I,bool)
text_in_doc_preprocess(const Image<I>& input_, unsigned lambda,
double K, bool enable_fg_bg, Image<I>& fg,
- bool verbose)
+ bool enable_deskew, bool verbose)
{
trace::entering("scribo::toolchain::text_in_doc_preprocess");
@@ -170,6 +170,7 @@ namespace scribo
f.sauvola_K = K;
f.enable_fg_extraction = enable_fg_bg;
f.lambda = lambda;
+ f.enable_deskew = enable_deskew;
f.verbose = verbose;
// Get results.
diff --git a/scribo/src/content_in_doc.cc b/scribo/src/content_in_doc.cc
index bd1109d..4d3c50e 100644
--- a/scribo/src/content_in_doc.cc
+++ b/scribo/src/content_in_doc.cc
@@ -67,6 +67,7 @@ static const scribo::debug::toggle_data toggle_desc[] =
"to improve layout detection. (default: enabled)", true },
{ "find-seps", "Find separators in document (default: enabled)", true },
{ "ocr", "Performs character recognition (default: enabled)", true },
+ { "deskew", "Deskew image (default: disabled)", false},
{0, 0, false}
};
@@ -117,10 +118,11 @@ int main(int argc, char* argv[])
image2d<value::rgb8> input;
mln::io::magick::load(input, options.arg("input.*"));
+ bool enable_deskew = options.is_enabled("deskew");
// Preprocess document
image2d<bool>
input_preproc = toolchain::text_in_doc_preprocess(input, false, 0,
- 0.34, verbose);
+ 0.34, enable_deskew, verbose);
// Optional Cropping
point2d crop_shift = literal::origin;
--
1.7.2.5
1
0