* scribo/binarization/internal/global_max_stddev_functor.hh: New.
* scribo/binarization/wolf.hh,
* scribo/binarization/wolf_fast.hh: Remove functor declaration.
---
scribo/ChangeLog | 9 ++
...olf_formula.hh => global_max_stddev_functor.hh} | 89 ++++++++++++--------
scribo/scribo/binarization/wolf.hh | 38 +--------
scribo/scribo/binarization/wolf_fast.hh | 38 +--------
4 files changed, 64 insertions(+), 110 deletions(-)
copy scribo/scribo/binarization/internal/{wolf_formula.hh =>
global_max_stddev_functor.hh} (54%)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index dd2346c..1fd80aa 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,3 +1,12 @@
+2013-03-22 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Share a functor used in Wolf's binarization.
+
+ * scribo/binarization/internal/global_max_stddev_functor.hh: New.
+
+ * scribo/binarization/wolf.hh,
+ * scribo/binarization/wolf_fast.hh: Remove functor declaration.
+
2013-03-20 Guillaume Lazzara <z(a)lrde.epita.fr>
* headers.mk: Regen.
diff --git a/scribo/scribo/binarization/internal/wolf_formula.hh
b/scribo/scribo/binarization/internal/global_max_stddev_functor.hh
similarity index 54%
copy from scribo/scribo/binarization/internal/wolf_formula.hh
copy to scribo/scribo/binarization/internal/global_max_stddev_functor.hh
index a3084a7..e10b77d 100644
--- a/scribo/scribo/binarization/internal/wolf_formula.hh
+++ b/scribo/scribo/binarization/internal/global_max_stddev_functor.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2013 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -23,25 +23,13 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_BINARIZATION_INTERNAL_WOLF_FORMULA_HH
-# define SCRIBO_BINARIZATION_INTERNAL_WOLF_FORMULA_HH
-
+#ifndef SCRIBO_BINARIZATION_INTERNAL_GLOBAL_MAX_STDDEV_FUNCTOR_HH
+# define SCRIBO_BINARIZATION_INTERNAL_GLOBAL_MAX_STDDEV_FUNCTOR_HH
/// \file
///
-/// \brief Routines computing a threshold using Wolf's binarization
-/// formula.
-
-
-// Setup default Wolf's formula parameters values.
-// These macros may be used in other variant of Wolf's algorithms.
-//
-// Values are set according to the following reference: <FIXME>
-
-# define SCRIBO_DEFAULT_WOLF_K 0.34
-
+///
-#include <mln/core/alias/point2d.hh>
namespace scribo
{
@@ -49,47 +37,76 @@ namespace scribo
namespace binarization
{
+ using namespace mln;
+
+
namespace internal
{
- using namespace mln;
+ /*! \internal \brief Functor computing the maximum standard
+ deviation during an integral image browsing.
- template <typename V>
- struct wolf_formula
+ It is used in Wolf's algorithm.
+ */
+ template <typename I>
+ struct global_max_stddev
{
+ global_max_stddev();
- /*! \brief Compute a threshold using Wolf's formula.
+ void init();
- \todo doc!
+ void exec(double mean, double stddev);
- \return A threshold.
- */
- double operator()(const double m_x_y, const double s_x_y,
- const double K, const double global_max_stddev,
- const V& global_min) const;
+ void end_of_row(int);
+ void finalize();
+
+ double max_stddev;
};
# ifndef MLN_INCLUDE_ONLY
+ template <typename I>
+ global_max_stddev<I>::global_max_stddev()
+ : max_stddev(0)
+ {
+ }
+
+ template <typename I>
+ void
+ global_max_stddev<I>::init()
+ {
+ }
- template <typename V>
- inline
- double
- wolf_formula<V>::operator()(const double m_x_y, const double s_x_y,
- const double K, const double global_max_stddev,
- const V& global_min) const
+ template <typename I>
+ void
+ global_max_stddev<I>::exec(double mean, double stddev)
{
- return m_x_y - K * (1 - s_x_y / global_max_stddev) * (m_x_y - global_min);
+ (void) mean;
+ if (max_stddev < stddev)
+ max_stddev = stddev;
}
-# endif // ! MLN_INCLUDE_ONLY
+ template <typename I>
+ void
+ global_max_stddev<I>::end_of_row(int)
+ {
+ }
+
+ template <typename I>
+ void
+ global_max_stddev<I>::finalize()
+ {
+ }
} // end of namespace scribo::binarization::internal
- } // end of namespace scribo::binarization
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace scribo::binarization
} // end of namespace scribo
-#endif // ! SCRIBO_BINARIZATION_INTERNAL_WOLF_FORMULA_HH
+
+#endif // ! SCRIBO_BINARIZATION_INTERNAL_GLOBAL_MAX_STDDEV_FUNCTOR_HH
diff --git a/scribo/scribo/binarization/wolf.hh b/scribo/scribo/binarization/wolf.hh
index 840d69f..300e93f 100644
--- a/scribo/scribo/binarization/wolf.hh
+++ b/scribo/scribo/binarization/wolf.hh
@@ -34,6 +34,7 @@
# include <mln/core/concept/image.hh>
# include <scribo/binarization/internal/wolf_functor.hh>
# include <scribo/binarization/internal/local_threshold_core.hh>
+# include <scribo/binarization/internal/global_max_stddev_functor.hh>
# include <scribo/util/integral_sum_sum2_global_min_functor.hh>
namespace scribo
@@ -93,43 +94,6 @@ namespace scribo
# ifndef MLN_INCLUDE_ONLY
- namespace internal
- {
-
- template <typename I>
- struct global_max_stddev
- {
- global_max_stddev()
- : max_stddev(0)
- {
- }
-
- void init()
- {
- }
-
- // Run every 4 pixels.
- void exec(double mean, double stddev)
- {
- (void) mean;
- if (max_stddev < stddev)
- max_stddev = stddev;
- }
-
- void end_of_row(int)
- {
- }
-
- void finalize()
- {
- }
-
- double max_stddev;
- };
-
- } // end of namespace scribo::binarization::internal
-
-
// Facades
template <typename I>
diff --git a/scribo/scribo/binarization/wolf_fast.hh
b/scribo/scribo/binarization/wolf_fast.hh
index a984532..d5a9a8f 100644
--- a/scribo/scribo/binarization/wolf_fast.hh
+++ b/scribo/scribo/binarization/wolf_fast.hh
@@ -34,6 +34,7 @@
# include <mln/core/concept/image.hh>
# include <scribo/binarization/internal/wolf_functor_fast.hh>
# include <scribo/binarization/internal/local_threshold_core.hh>
+# include <scribo/binarization/internal/global_max_stddev_functor.hh>
# include <scribo/util/integral_sum_sum2_global_min_functor.hh>
namespace scribo
@@ -92,43 +93,6 @@ namespace scribo
# ifndef MLN_INCLUDE_ONLY
- namespace internal
- {
-
- template <typename I>
- struct global_max_stddev
- {
- global_max_stddev()
- : max_stddev(0)
- {
- }
-
- void init()
- {
- }
-
- // Run every 4 pixels.
- void exec(double mean, double stddev)
- {
- (void) mean;
- if (max_stddev < stddev)
- max_stddev = stddev;
- }
-
- void end_of_row(int)
- {
- }
-
- void finalize()
- {
- }
-
- double max_stddev;
- };
-
- } // end of namespace scribo::binarization::internal
-
-
// Facades
template <typename I>
--
1.7.2.5