---
.../binarization/internal/sauvola_ms_functor.hh | 3 +--
scribo/scribo/binarization/sauvola_ms.hh | 7 ++++---
scribo/src/binarization/otsu.cc | 10 ++++++++++
scribo/src/binarization/sauvola.cc | 10 ++++++++++
4 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/scribo/scribo/binarization/internal/sauvola_ms_functor.hh
b/scribo/scribo/binarization/internal/sauvola_ms_functor.hh
index cbace88..3411d1b 100644
--- a/scribo/scribo/binarization/internal/sauvola_ms_functor.hh
+++ b/scribo/scribo/binarization/internal/sauvola_ms_functor.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.
@@ -205,7 +205,6 @@ namespace scribo
template <typename I>
void sauvola_ms_functor<I>::finalize()
{
- std::cout << "Scale " << i_ << " - K = " <<
K_ << std::endl;
mln_assertion(! pxl.is_valid());
}
diff --git a/scribo/scribo/binarization/sauvola_ms.hh
b/scribo/scribo/binarization/sauvola_ms.hh
index a740ec0..96064e9 100644
--- a/scribo/scribo/binarization/sauvola_ms.hh
+++ b/scribo/scribo/binarization/sauvola_ms.hh
@@ -159,7 +159,7 @@ namespace scribo
w_local_h = w_local,
w_local_w = w_local;
- std::cout << "scale " << i << " - w = " << w
<< " - lambda_min = " << lambda_min << " - lambda_max =
" << lambda_max << std::endl;
+ //std::cout << "scale " << i << " - w = " <<
w << " - lambda_min = " << lambda_min << " - lambda_max =
" << lambda_max << std::endl;
// Make sure the window fits in the image domain.
if (w_local_w >= static_cast<const unsigned>(integral_sum_sum_2.ncols()))
@@ -185,7 +185,7 @@ namespace scribo
++w_local_h;
}
- std::cout << "Scale " << i << " - w_h = " <<
w_local_h << " - w_w = " << w_local_w << " - w = "
<< w << std::endl;
+ //std::cout << "Scale " << i << " - w_h = "
<< w_local_h << " - w_w = " << w_local_w << " - w =
" << w << std::endl;
// 1st pass
scribo::binarization::internal::sauvola_ms_functor< image2d<int_u8> >
@@ -196,7 +196,7 @@ namespace scribo
s,
f);
- std::cout << " i = " << i << " - ratio = "
<< ratio << std::endl;
+ //std::cout << " i = " << i << " - ratio = "
<< ratio << std::endl;
// 2nd pass
{
@@ -807,6 +807,7 @@ namespace scribo
trace::entering("scribo::binarization::sauvola_ms");
const I& input_1 = exact(input_1_);
+ typedef mln_value(I) V;
mlc_is_a(mln_value(I), value::Scalar)::check();
mln_precondition(input_1.is_valid());
diff --git a/scribo/src/binarization/otsu.cc b/scribo/src/binarization/otsu.cc
index ebd5da4..eb60973 100644
--- a/scribo/src/binarization/otsu.cc
+++ b/scribo/src/binarization/otsu.cc
@@ -28,7 +28,9 @@
#include <mln/io/magick/load.hh>
#include <mln/io/pbm/save.hh>
#include <mln/data/transform.hh>
+#include <mln/arith/revert.hh>
#include <mln/fun/v2v/rgb_to_luma.hh>
+#include <mln/logical/not.hh>
#include <scribo/binarization/otsu.hh>
#include <scribo/debug/option_parser.hh>
@@ -46,6 +48,8 @@ static const scribo::debug::arg_data arg_desc[] =
static const scribo::debug::toggle_data toggle_desc[] =
{
// name, description, default value
+ { "negate-input", "Negate input image before binarizing.", false
},
+ { "negate-output", "Negate output image before binarizing.", false
},
{0, 0, false}
};
@@ -92,8 +96,14 @@ int main(int argc, char *argv[])
image2d<value::int_u8>
input_1_gl = data::transform(input,
mln::fun::v2v::rgb_to_luma<value::int_u8>());
+ if (options.is_enabled("negate-input"))
+ input_1_gl = arith::revert(input_1_gl);
+
image2d<bool> out = scribo::binarization::otsu(input_1_gl);
+ if (options.is_enabled("negate-output"))
+ logical::not_inplace(out);
+
io::pbm::save(out, options.arg("output.pbm"));
trace::exiting("main");
diff --git a/scribo/src/binarization/sauvola.cc b/scribo/src/binarization/sauvola.cc
index 518937b..6ea224c 100644
--- a/scribo/src/binarization/sauvola.cc
+++ b/scribo/src/binarization/sauvola.cc
@@ -99,8 +99,18 @@ int main(int argc, char *argv[])
image2d<value::int_u8>
input_1_gl = data::transform(input,
mln::fun::v2v::rgb_to_luma<value::int_u8>());
+ mln::util::timer t;
+ t.start();
+
+ // Binarize
image2d<bool> out = scribo::binarization::sauvola(input_1_gl, w, k);
+ if (verbose)
+ {
+ t.stop();
+ std::cout << "binarized in " << t << "s"
<< std::endl;
+ }
+
io::pbm::save(out, options.arg("output.pbm"));
trace::exiting("main");
--
1.7.2.5