* apps/papers/levillain.09.ismm/graph.cc,
* doc/examples/tuto4_genericity_and_algorithms.cc,
* mln/binarization/threshold.hh,
* mln/fun/v2b/all.hh,
* mln/fun/v2b/essential.hh,
* mln/world/binary_2d/enlarge.hh,
* tests/labeling/n_max.cc: Update includes and use of threshold
function.
* mln/fun/v2b/threshold.hh: Replaced...
* mln/fun/v2b/threshold_ge.hh,
* mln/fun/v2b/threshold_le.hh: ... by these files.
* tests/unit_test/unit-tests.mk: Regen.
---
milena/ChangeLog | 20 ++++++++++++++++++++
milena/apps/papers/levillain.09.ismm/graph.cc | 7 ++++---
.../examples/tuto4_genericity_and_algorithms.cc | 5 ++---
milena/mln/binarization/threshold.hh | 7 ++++---
milena/mln/fun/v2b/all.hh | 6 ++++--
milena/mln/fun/v2b/essential.hh | 6 ++++--
.../mln/fun/v2b/{threshold.hh => threshold_ge.hh} | 16 ++++++++--------
.../mln/fun/v2b/{threshold.hh => threshold_le.hh} | 16 ++++++++--------
milena/mln/world/binary_2d/enlarge.hh | 6 ++++--
milena/tests/labeling/n_max.cc | 4 ++--
milena/tests/unit_test/unit-tests.mk | 10 ++++++++--
11 files changed, 68 insertions(+), 35 deletions(-)
copy milena/mln/fun/v2b/{threshold.hh => threshold_ge.hh} (86%)
rename milena/mln/fun/v2b/{threshold.hh => threshold_le.hh} (85%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index e9d45f1..733afe4 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,23 @@
+2011-11-22 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Add two variants of the threshold function.
+
+ * apps/papers/levillain.09.ismm/graph.cc,
+ * doc/examples/tuto4_genericity_and_algorithms.cc,
+ * mln/binarization/threshold.hh,
+ * mln/fun/v2b/all.hh,
+ * mln/fun/v2b/essential.hh,
+ * mln/world/binary_2d/enlarge.hh,
+ * tests/labeling/n_max.cc: Update includes and use of threshold
+ function.
+
+ * mln/fun/v2b/threshold.hh: Replaced...
+
+ * mln/fun/v2b/threshold_ge.hh,
+ * mln/fun/v2b/threshold_le.hh: ... by these files.
+
+ * tests/unit_test/unit-tests.mk: Regen.
+
2011-11-21 Guillaume Lazzara <z(a)lrde.epita.fr>
* mln/geom/crop_without_localization.hh: Fix preconditions.
diff --git a/milena/apps/papers/levillain.09.ismm/graph.cc
b/milena/apps/papers/levillain.09.ismm/graph.cc
index 507bbc5..bf37df2 100644
--- a/milena/apps/papers/levillain.09.ismm/graph.cc
+++ b/milena/apps/papers/levillain.09.ismm/graph.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009, 2011 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -37,7 +38,7 @@
#include <mln/debug/println.hh>
#include <mln/draw/line.hh>
#include <mln/pw/all.hh>
-#include <mln/binarization/threshold.hh>
+#include <mln/binarization/threshold_ge.hh>
#include <mln/value/int_u8.hh>
#include <mln/value/label_8.hh>
@@ -313,7 +314,7 @@ make_complex_image(const mln::image2d<mln::value::int_u8>&
input)
unsigned nlabels;
image2d<unsigned> label =
- labeling::blobs(mln::binarization::threshold(input, 1), c4(), nlabels);
+ labeling::blobs(mln::binarization::threshold_ge(input, 1), c4(), nlabels);
std::cout << "n seeds = " << nlabels << std::endl;
{
diff --git a/milena/doc/examples/tuto4_genericity_and_algorithms.cc
b/milena/doc/examples/tuto4_genericity_and_algorithms.cc
index 78237a4..dcc57a3 100644
--- a/milena/doc/examples/tuto4_genericity_and_algorithms.cc
+++ b/milena/doc/examples/tuto4_genericity_and_algorithms.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2011 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -49,8 +50,6 @@
#include <mln/pw/all.hh>
-#include <mln/binarization/threshold.hh>
-
#include <mln/labeling/colorize.hh>
#include <mln/labeling/blobs.hh>
diff --git a/milena/mln/binarization/threshold.hh b/milena/mln/binarization/threshold.hh
index 23acbe0..f29bb7c 100644
--- a/milena/mln/binarization/threshold.hh
+++ b/milena/mln/binarization/threshold.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009, 2011 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -31,7 +32,7 @@
/// \brief Threshold an image.
# include <mln/binarization/binarization.hh>
-# include <mln/fun/v2b/threshold.hh>
+# include <mln/fun/v2b/threshold_ge.hh>
namespace mln
@@ -69,7 +70,7 @@ namespace mln
mln_ch_value(I, bool) output(exact(input).domain());
// FIXME : threshold value should be a percentage.
- fun::v2b::threshold< mln_value(I) > f(threshold_value);
+ fun::v2b::threshold_ge< mln_value(I) > f(threshold_value);
output = mln::binarization::binarization(exact(input), f);
diff --git a/milena/mln/fun/v2b/all.hh b/milena/mln/fun/v2b/all.hh
index 00aede2..b138f56 100644
--- a/milena/mln/fun/v2b/all.hh
+++ b/milena/mln/fun/v2b/all.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009, 2011 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -45,7 +46,8 @@ namespace mln
# include <mln/fun/v2b/lnot.hh>
-# include <mln/fun/v2b/threshold.hh>
+# include <mln/fun/v2b/threshold_le.hh>
+# include <mln/fun/v2b/threshold_ge.hh>
#endif // ! MLN_FUN_V2B_ALL_HH
diff --git a/milena/mln/fun/v2b/essential.hh b/milena/mln/fun/v2b/essential.hh
index 0f21bc6..7e77a4b 100644
--- a/milena/mln/fun/v2b/essential.hh
+++ b/milena/mln/fun/v2b/essential.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009, 2011 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -31,6 +32,7 @@
* \brief File that includes essential functions from point to value.
*/
-# include <mln/fun/v2b/threshold.hh>
+# include <mln/fun/v2b/threshold_ge.hh>
+# include <mln/fun/v2b/threshold_le.hh>
#endif // ! MLN_FUN_V2B_ESSENTIAL_HH
diff --git a/milena/mln/fun/v2b/threshold.hh b/milena/mln/fun/v2b/threshold_ge.hh
similarity index 86%
copy from milena/mln/fun/v2b/threshold.hh
copy to milena/mln/fun/v2b/threshold_ge.hh
index 5a8e8e9..c5fef9e 100644
--- a/milena/mln/fun/v2b/threshold.hh
+++ b/milena/mln/fun/v2b/threshold_ge.hh
@@ -24,8 +24,8 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef MLN_FUN_V2B_THRESHOLD_HH
-# define MLN_FUN_V2B_THRESHOLD_HH
+#ifndef MLN_FUN_V2B_THRESHOLD_GE_HH
+# define MLN_FUN_V2B_THRESHOLD_GE_HH
/// \file
///
@@ -46,12 +46,12 @@ namespace mln
/// Threshold function.
/// f(v) = (v >= threshold).
template <typename V>
- struct threshold : public Function_v2b< threshold<V> >
+ struct threshold_ge : public Function_v2b< threshold_ge<V> >
{
typedef bool result;
bool operator()(const V& v) const;
- threshold(const V& a);
+ threshold_ge(const V& a);
V a;
};
@@ -60,7 +60,7 @@ namespace mln
template <typename V>
inline
- threshold<V>::threshold(const V& a)
+ threshold_ge<V>::threshold_ge(const V& a)
: a(a)
{
}
@@ -68,12 +68,12 @@ namespace mln
template <typename V>
inline
bool
- threshold<V>::operator()(const V& v) const
+ threshold_ge<V>::operator()(const V& v) const
{
// Here the test seems to be inversed compared to the usual
// use. Indeed, we want to preserve the following convention:
// True for foreground and False for background.
- return v <= a;
+ return v >= a;
}
# endif // ! MLN_INCLUDE_ONLY
@@ -85,4 +85,4 @@ namespace mln
} // end of namespace mln
-#endif // ! MLN_FUN_V2B_THRESHOLD_HH
+#endif // ! MLN_FUN_V2B_THRESHOLD_GE_HH
diff --git a/milena/mln/fun/v2b/threshold.hh b/milena/mln/fun/v2b/threshold_le.hh
similarity index 85%
rename from milena/mln/fun/v2b/threshold.hh
rename to milena/mln/fun/v2b/threshold_le.hh
index 5a8e8e9..21964c8 100644
--- a/milena/mln/fun/v2b/threshold.hh
+++ b/milena/mln/fun/v2b/threshold_le.hh
@@ -24,8 +24,8 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef MLN_FUN_V2B_THRESHOLD_HH
-# define MLN_FUN_V2B_THRESHOLD_HH
+#ifndef MLN_FUN_V2B_THRESHOLD_LE_HH
+# define MLN_FUN_V2B_THRESHOLD_LE_HH
/// \file
///
@@ -44,14 +44,14 @@ namespace mln
{
/// Threshold function.
- /// f(v) = (v >= threshold).
+ /// f(v) = (v <= threshold).
template <typename V>
- struct threshold : public Function_v2b< threshold<V> >
+ struct threshold_le : public Function_v2b< threshold_le<V> >
{
typedef bool result;
bool operator()(const V& v) const;
- threshold(const V& a);
+ threshold_le(const V& a);
V a;
};
@@ -60,7 +60,7 @@ namespace mln
template <typename V>
inline
- threshold<V>::threshold(const V& a)
+ threshold_le<V>::threshold_le(const V& a)
: a(a)
{
}
@@ -68,7 +68,7 @@ namespace mln
template <typename V>
inline
bool
- threshold<V>::operator()(const V& v) const
+ threshold_le<V>::operator()(const V& v) const
{
// Here the test seems to be inversed compared to the usual
// use. Indeed, we want to preserve the following convention:
@@ -85,4 +85,4 @@ namespace mln
} // end of namespace mln
-#endif // ! MLN_FUN_V2B_THRESHOLD_HH
+#endif // ! MLN_FUN_V2B_THRESHOLD_LE_HH
diff --git a/milena/mln/world/binary_2d/enlarge.hh
b/milena/mln/world/binary_2d/enlarge.hh
index 1ffd512..d7535cb 100644
--- a/milena/mln/world/binary_2d/enlarge.hh
+++ b/milena/mln/world/binary_2d/enlarge.hh
@@ -40,7 +40,7 @@
# include <mln/value/int_u8.hh>
# include <mln/fun/p2v/ternary.hh>
-# include <mln/fun/v2b/threshold.hh>
+# include <mln/fun/v2b/threshold_ge.hh>
# include <mln/data/transform.hh>
@@ -54,6 +54,7 @@
# include <mln/core/routine/duplicate.hh>
+#include <mln/debug/println.hh>
namespace mln
{
@@ -291,8 +292,9 @@ namespace mln
do_enlarge_bool(const I& input, unsigned n)
{
mln_ch_value(I,value::int_u8) tmp = do_enlarge_gl(input, n);
+ debug::println(tmp);
I output
- = data::transform(tmp, fun::v2b::threshold<value::int_u8>(150));
+ = data::transform(tmp, fun::v2b::threshold_ge<value::int_u8>(160));
return output;
}
diff --git a/milena/tests/labeling/n_max.cc b/milena/tests/labeling/n_max.cc
index 0eba6cd..1b70a7e 100644
--- a/milena/tests/labeling/n_max.cc
+++ b/milena/tests/labeling/n_max.cc
@@ -32,7 +32,7 @@
#include <mln/labeling/compute.hh>
#include <mln/labeling/n_max.hh>
-#include <mln/fun/v2b/threshold.hh>
+#include <mln/fun/v2b/threshold_le.hh>
#include <mln/data/transform.hh>
#include <mln/accu/math/count.hh>
@@ -49,7 +49,7 @@ int main()
image2d<int_u8> lena = io::pgm::load<int_u8>(MLN_IMG_DIR
"/tiny.pgm");
- image2d<bool> threshold = data::transform(lena,
fun::v2b::threshold<int_u8>(100));
+ image2d<bool> threshold = data::transform(lena,
fun::v2b::threshold_le<int_u8>(100));
label_8 nlabels;
image2d<label_8> labels = labeling::flat_zones(threshold, c4(), nlabels);
accu::math::count<int_u8> a_;
diff --git a/milena/tests/unit_test/unit-tests.mk b/milena/tests/unit_test/unit-tests.mk
index 2519bd6..3a14188 100644
--- a/milena/tests/unit_test/unit-tests.mk
+++ b/milena/tests/unit_test/unit-tests.mk
@@ -652,7 +652,8 @@ mln_fun_unary_param \
mln_fun_v2b_all \
mln_fun_v2b_essential \
mln_fun_v2b_lnot \
-mln_fun_v2b_threshold \
+mln_fun_v2b_threshold_ge \
+mln_fun_v2b_threshold_le \
mln_fun_v2i_all \
mln_fun_v2i_index_of_value \
mln_fun_v2v_abs \
@@ -720,6 +721,8 @@ mln_geom_all \
mln_geom_bbox \
mln_geom_chamfer \
mln_geom_complex_geometry \
+mln_geom_crop \
+mln_geom_crop_without_localization \
mln_geom_delta \
mln_geom_essential \
mln_geom_horizontal_symmetry \
@@ -1979,7 +1982,8 @@ mln_fun_unary_param_SOURCES = mln_fun_unary_param.cc
mln_fun_v2b_all_SOURCES = mln_fun_v2b_all.cc
mln_fun_v2b_essential_SOURCES = mln_fun_v2b_essential.cc
mln_fun_v2b_lnot_SOURCES = mln_fun_v2b_lnot.cc
-mln_fun_v2b_threshold_SOURCES = mln_fun_v2b_threshold.cc
+mln_fun_v2b_threshold_ge_SOURCES = mln_fun_v2b_threshold_ge.cc
+mln_fun_v2b_threshold_le_SOURCES = mln_fun_v2b_threshold_le.cc
mln_fun_v2i_all_SOURCES = mln_fun_v2i_all.cc
mln_fun_v2i_index_of_value_SOURCES = mln_fun_v2i_index_of_value.cc
mln_fun_v2v_abs_SOURCES = mln_fun_v2v_abs.cc
@@ -2047,6 +2051,8 @@ mln_geom_all_SOURCES = mln_geom_all.cc
mln_geom_bbox_SOURCES = mln_geom_bbox.cc
mln_geom_chamfer_SOURCES = mln_geom_chamfer.cc
mln_geom_complex_geometry_SOURCES = mln_geom_complex_geometry.cc
+mln_geom_crop_SOURCES = mln_geom_crop.cc
+mln_geom_crop_without_localization_SOURCES = mln_geom_crop_without_localization.cc
mln_geom_delta_SOURCES = mln_geom_delta.cc
mln_geom_essential_SOURCES = mln_geom_essential.cc
mln_geom_horizontal_symmetry_SOURCES = mln_geom_horizontal_symmetry.cc
--
1.7.2.5