* src/binarization/global_threshold.cc,
* src/binarization/kim.cc,
* src/binarization/niblack.cc,
* src/binarization/otsu.cc,
* src/binarization/sauvola.cc,
* src/binarization/sauvola_ms.cc,
* src/binarization/sauvola_ms_debug.cc,
* src/binarization/sauvola_ms_fg.cc,
* src/binarization/sauvola_ms_split.cc,
* src/binarization/wolf.cc: Make use of operator<<.
---
scribo/ChangeLog | 15 +++++++++++++++
scribo/src/binarization/global_threshold.cc | 10 +++++-----
scribo/src/binarization/kim.cc | 13 +++++--------
scribo/src/binarization/niblack.cc | 10 +++++-----
scribo/src/binarization/otsu.cc | 9 ++++-----
scribo/src/binarization/sauvola.cc | 18 ++++++------------
scribo/src/binarization/sauvola_ms.cc | 21 ++++++++-------------
scribo/src/binarization/sauvola_ms_debug.cc | 20 +++++++-------------
scribo/src/binarization/sauvola_ms_fg.cc | 11 +++++------
scribo/src/binarization/sauvola_ms_split.cc | 15 ++++++---------
scribo/src/binarization/wolf.cc | 9 ++++-----
11 files changed, 70 insertions(+), 81 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index fc9ff14..521ad29 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,20 @@
2012-08-23 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Make use of new logger features.
+
+ * src/binarization/global_threshold.cc,
+ * src/binarization/kim.cc,
+ * src/binarization/niblack.cc,
+ * src/binarization/otsu.cc,
+ * src/binarization/sauvola.cc,
+ * src/binarization/sauvola_ms.cc,
+ * src/binarization/sauvola_ms_debug.cc,
+ * src/binarization/sauvola_ms_fg.cc,
+ * src/binarization/sauvola_ms_split.cc,
+ * src/binarization/wolf.cc: Make use of operator<<.
+
+2012-08-23 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Cleanup Kim's binarization.
* src/binarization/kim.cc: Move code...
diff --git a/scribo/src/binarization/global_threshold.cc
b/scribo/src/binarization/global_threshold.cc
index 276ec2e..eaf11c7 100644
--- a/scribo/src/binarization/global_threshold.cc
+++ b/scribo/src/binarization/global_threshold.cc
@@ -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.
//
@@ -57,7 +58,8 @@ static const scribo::debug::opt_data opt_desc[] =
// name, description, arguments, check args function, number of args, default arg
{ "debug-prefix", "Enable debug image outputs. Prefix image name with
that "
"given prefix.", "<prefix>", 0, 1, 0 },
- { "verbose", "Enable verbose mode", 0, 0, 0, 0 },
+ { "verbose", "Enable verbose mode (mute, time, low, medium,
full)",
+ "<mode>", scribo::debug::check_verbose_mode, 1, "mute" },
{0, 0, 0, 0, 0, 0}
};
@@ -83,11 +85,9 @@ int main(int argc, char *argv[])
trace::entering("main");
- bool verbose = options.is_set("verbose");
unsigned threshold = atoi(options.arg("threshold_value"));
- if (verbose)
- std::cout << "Using threshold=" << threshold <<
std::endl;
+ scribo::debug::logger() << "Using threshold=" << threshold
<< std::endl;
image2d<value::rgb8> input;
io::magick::load(input, options.arg("input.*"));
diff --git a/scribo/src/binarization/kim.cc b/scribo/src/binarization/kim.cc
index 9f9c38f..0a064d8 100644
--- a/scribo/src/binarization/kim.cc
+++ b/scribo/src/binarization/kim.cc
@@ -59,7 +59,8 @@ static const scribo::debug::opt_data opt_desc[] =
{ "debug-prefix", "Enable debug image outputs. Prefix image name with
that "
"given prefix.", "<prefix>", 0, 1, 0 },
{ "k", "Sauvola's formulae parameter",
"<value>", 0, 1, "0.34" },
- { "verbose", "Enable verbose mode", 0, 0, 0, 0 },
+ { "verbose", "Enable verbose mode (mute, time, low, medium,
full)",
+ "<mode>", scribo::debug::check_verbose_mode, 1, "mute" },
{ "win-size", "Window size at scale 1", "<size>",
0, 1, "101" },
{0, 0, 0, 0, 0, 0}
};
@@ -90,13 +91,9 @@ int main(int argc, char *argv[])
unsigned w_1 = atoi(options.opt_value("win-size").c_str());
double k = atof(options.opt_value("k").c_str());
- if (options.is_set("verbose"))
- {
- scribo::debug::logger().set_verbose_mode(
- scribo::debug::txt_to_verbose_mode(options.opt_value("verbose")));
- scribo::debug::logger().log(Low, std::string("Using w_1=") + w_1
- + std::string(" - k=") + k);
- }
+ scribo::debug::logger() << "Using w_1=" << w_1
+ << " - k=" << k << std::endl;
+
// Load
image2d<value::rgb8> input_1;
diff --git a/scribo/src/binarization/niblack.cc b/scribo/src/binarization/niblack.cc
index 58074fc..7c14c45 100644
--- a/scribo/src/binarization/niblack.cc
+++ b/scribo/src/binarization/niblack.cc
@@ -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.
//
@@ -59,7 +60,8 @@ static const scribo::debug::opt_data opt_desc[] =
{ "debug-prefix", "Enable debug image outputs. Prefix image name with
that "
"given prefix.", "<prefix>", 0, 1, 0 },
{ "k", "Niblack's formulae parameter",
"<value>", 0, 1, "-0.2" },
- { "verbose", "Enable verbose mode", 0, 0, 0, 0 },
+ { "verbose", "Enable verbose mode (mute, time, low, medium,
full)",
+ "<mode>", scribo::debug::check_verbose_mode, 1, "mute" },
{ "win-size", "Window size", "<size>", 0, 1,
"101" },
{0, 0, 0, 0, 0, 0}
};
@@ -86,12 +88,10 @@ int main(int argc, char *argv[])
trace::entering("main");
- bool verbose = options.is_set("verbose");
unsigned w = atoi(options.opt_value("win-size").c_str());
double k = atof(options.opt_value("k").c_str());
- if (verbose)
- std::cout << "Using w=" << w << " and k="
<< k << std::endl;
+ scribo::debug::logger() << "Using w=" << w << " and
k=" << k << std::endl;
image2d<value::rgb8> input;
io::magick::load(input, options.arg("input.*"));
diff --git a/scribo/src/binarization/otsu.cc b/scribo/src/binarization/otsu.cc
index eb60973..dcdae1d 100644
--- a/scribo/src/binarization/otsu.cc
+++ b/scribo/src/binarization/otsu.cc
@@ -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.
//
@@ -60,7 +61,8 @@ static const scribo::debug::opt_data opt_desc[] =
// name, description, arguments, check args function, number of args, default arg
{ "debug-prefix", "Enable debug image outputs. Prefix image name with
that "
"given prefix.", "<prefix>", 0, 1, 0 },
- { "verbose", "Enable verbose mode", 0, 0, 0, 0 },
+ { "verbose", "Enable verbose mode (mute, time, low, medium,
full)",
+ "<mode>", scribo::debug::check_verbose_mode, 1, "mute" },
{0, 0, 0, 0, 0, 0}
};
@@ -86,9 +88,6 @@ int main(int argc, char *argv[])
trace::entering("main");
- bool verbose = options.is_set("verbose");
- (void) verbose;
-
image2d<value::rgb8> input;
io::magick::load(input, options.arg("input.*"));
diff --git a/scribo/src/binarization/sauvola.cc b/scribo/src/binarization/sauvola.cc
index 6ea224c..3549585 100644
--- a/scribo/src/binarization/sauvola.cc
+++ b/scribo/src/binarization/sauvola.cc
@@ -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.
@@ -58,7 +58,8 @@ static const scribo::debug::opt_data opt_desc[] =
{ "debug-prefix", "Enable debug image outputs. Prefix image name with
that "
"given prefix.", "<prefix>", 0, 1, 0 },
{ "k", "Sauvola's formulae parameter",
"<value>", 0, 1, "0.34" },
- { "verbose", "Enable verbose mode", 0, 0, 0, 0 },
+ { "verbose", "Enable verbose mode (mute, time, low, medium,
full)",
+ "<mode>", scribo::debug::check_verbose_mode, 1, "mute" },
{ "win-size", "Window size", "<size>", 0, 1,
"101" },
{0, 0, 0, 0, 0, 0}
};
@@ -85,12 +86,10 @@ int main(int argc, char *argv[])
trace::entering("main");
- bool verbose = options.is_set("verbose");
unsigned w = atoi(options.opt_value("win-size").c_str());
double k = atof(options.opt_value("k").c_str());
- if (verbose)
- std::cout << "Using w=" << w << " and k="
<< k << std::endl;
+ scribo::debug::logger() << "Using w=" << w << " and
k=" << k << std::endl;
image2d<value::rgb8> input;
io::magick::load(input, options.arg("input.*"));
@@ -99,17 +98,12 @@ 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();
+ scribo::debug::logger().start_local_time_logging();
// Binarize
image2d<bool> out = scribo::binarization::sauvola(input_1_gl, w, k);
- if (verbose)
- {
- t.stop();
- std::cout << "binarized in " << t << "s"
<< std::endl;
- }
+ scribo::debug::logger().stop_local_time_logging("Binarized in");
io::pbm::save(out, options.arg("output.pbm"));
diff --git a/scribo/src/binarization/sauvola_ms.cc
b/scribo/src/binarization/sauvola_ms.cc
index d07de72..c5ab3e4 100644
--- a/scribo/src/binarization/sauvola_ms.cc
+++ b/scribo/src/binarization/sauvola_ms.cc
@@ -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.
@@ -70,7 +70,8 @@ static const scribo::debug::opt_data opt_desc[] =
{ "s", "First subsampling ratio. Possible values: 2 or 3.",
"ratio",
scribo::debug::check_sauvola_first_subsampling, 1, "3" },
- { "verbose", "Enable verbose mode", 0, 0, 0, 0 },
+ { "verbose", "Enable verbose mode (mute, time, low, medium,
full)",
+ "<mode>", scribo::debug::check_verbose_mode, 1, "mute" },
{ "win-size", "Window size at scale 1", "<size>",
0, 1, "101" },
{0, 0, 0, 0, 0, 0}
};
@@ -102,7 +103,6 @@ int main(int argc, char *argv[])
trace::entering("main");
- bool verbose = options.is_set("verbose");
// Window size
unsigned w_1 = atoi(options.opt_value("win-size").c_str());
// First subsampling scale.
@@ -122,9 +122,8 @@ int main(int argc, char *argv[])
binarization::internal::k4 = atof(options.opt_value("k4").c_str());
}
- if (verbose)
- std::cout << "Using w_1=" << w_1 << " - s="
<< s
- << " - k=" << k << std::endl;
+ scribo::debug::logger() << "Using w_1=" << w_1 << " -
s=" << s
+ << " - k=" << k << std::endl;
@@ -137,18 +136,14 @@ int main(int argc, char *argv[])
input_1_gl = data::transform(input_1,
mln::fun::v2v::rgb_to_luma<value::int_u8>());
- mln::util::timer t;
- t.start();
+
+ scribo::debug::logger().start_local_time_logging();
// Binarize
image2d<bool>
output = scribo::binarization::sauvola_ms(input_1_gl, w_1, s, k);
- if (verbose)
- {
- t.stop();
- std::cout << "binarized in " << t << "s"
<< std::endl;
- }
+ scribo::debug::logger().stop_local_time_logging("Binarized in");
io::pbm::save(output, options.arg("output.pbm"));
}
diff --git a/scribo/src/binarization/sauvola_ms_debug.cc
b/scribo/src/binarization/sauvola_ms_debug.cc
index d89e9f4..251f0e8 100644
--- a/scribo/src/binarization/sauvola_ms_debug.cc
+++ b/scribo/src/binarization/sauvola_ms_debug.cc
@@ -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.
@@ -72,7 +72,8 @@ static const scribo::debug::opt_data opt_desc[] =
{ "s", "First subsampling ratio. Possible values: 2 or 3.",
"ratio",
scribo::debug::check_sauvola_first_subsampling, 1, "3" },
- { "verbose", "Enable verbose mode", 0, 0, 0, 0 },
+ { "verbose", "Enable verbose mode (mute, time, low, medium,
full)",
+ "<mode>", scribo::debug::check_verbose_mode, 1, "mute" },
{ "win-size", "Window size at scale 1", "<size>",
0, 1, "101" },
{0, 0, 0, 0, 0, 0}
};
@@ -131,7 +132,6 @@ int main(int argc, char *argv[])
trace::entering("main");
- bool verbose = options.is_set("verbose");
// Window size
unsigned w_1 = atoi(options.opt_value("win-size").c_str());
// First subsampling scale.
@@ -142,9 +142,8 @@ int main(int argc, char *argv[])
binarization::internal::k3 = atof(options.opt_value("k3").c_str());
binarization::internal::k4 = atof(options.opt_value("k4").c_str());
- if (verbose)
- std::cout << "Using w_1=" << w_1 << " - s="
<< s
- << " - k=" << k << std::endl;
+ scribo::debug::logger() << "Using w_1=" << w_1 << " -
s=" << s
+ << " - k=" << k << std::endl;
scribo::binarization::internal::scale_image_output = "scale_image.pgm";
scribo::binarization::internal::threshold_image_output =
"threshold_image.pbm";
@@ -162,18 +161,13 @@ int main(int argc, char *argv[])
input_1_gl = data::transform(input_1,
mln::fun::v2v::rgb_to_luma<value::int_u8>());
- mln::util::timer t;
- t.start();
+ scribo::debug::logger().start_local_time_logging();
// Binarize.
image2d<bool>
output = scribo::binarization::sauvola_ms(input_1_gl, w_1, s, k);
- if (verbose)
- {
- t.stop();
- std::cout << "binarized in " << t << "s"
<< std::endl;
- }
+ scribo::debug::logger().stop_local_time_logging("Binarized in");
# ifdef SCRIBO_LOCAL_THRESHOLD_DEBUG
{
diff --git a/scribo/src/binarization/sauvola_ms_fg.cc
b/scribo/src/binarization/sauvola_ms_fg.cc
index 83a48af..98206a8 100644
--- a/scribo/src/binarization/sauvola_ms_fg.cc
+++ b/scribo/src/binarization/sauvola_ms_fg.cc
@@ -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.
@@ -65,7 +65,8 @@ static const scribo::debug::opt_data opt_desc[] =
"useful if fg-extraction is enabled.", "<size>", 0, 1,
"1024" },
{ "s", "First subsampling ratio. Possible values: 2 or 3.",
"ratio",
scribo::debug::check_sauvola_first_subsampling, 1, "3" },
- { "verbose", "Enable verbose mode", 0, 0, 0, 0 },
+ { "verbose", "Enable verbose mode (mute, time, low, medium,
full)",
+ "<mode>", scribo::debug::check_verbose_mode, 1, "mute" },
{ "win-size", "Window size at scale 1", "<size>",
0, 1, "101" },
{0, 0, 0, 0, 0, 0}
};
@@ -92,7 +93,6 @@ int main(int argc, char *argv[])
trace::entering("main");
- bool verbose = options.is_set("verbose");
unsigned lambda = atoi(options.opt_value("lambda").c_str());
// Window size
@@ -102,9 +102,8 @@ int main(int argc, char *argv[])
unsigned s = atoi(options.opt_value("s").c_str());
double k = atof(options.opt_value("k").c_str());
- if (verbose)
- std::cout << "Using w_1=" << w_1 << " - s="
<< s << " - k="
- << k << " - lambda=" << lambda << std::endl;
+ scribo::debug::logger() << "Using w_1=" << w_1 << " -
s=" << s << " - k="
+ << k << " - lambda=" << lambda << std::endl;
Magick::InitializeMagick(0);
diff --git a/scribo/src/binarization/sauvola_ms_split.cc
b/scribo/src/binarization/sauvola_ms_split.cc
index f71f734..f1cc490 100644
--- a/scribo/src/binarization/sauvola_ms_split.cc
+++ b/scribo/src/binarization/sauvola_ms_split.cc
@@ -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.
//
@@ -67,7 +67,8 @@ static const scribo::debug::opt_data opt_desc[] =
"<num>", scribo::debug::check_sauvola_split_ntrue, 1, "2"
},
{ "s", "First subsampling ratio. Possible values: 2 or 3.",
"ratio",
scribo::debug::check_sauvola_first_subsampling, 1, "3" },
- { "verbose", "Enable verbose mode", 0, 0, 0, 0 },
+ { "verbose", "Enable verbose mode (mute, time, low, medium,
full)",
+ "<mode>", scribo::debug::check_verbose_mode, 1, "mute" },
{ "win-size", "Window size at scale 1", "<size>",
0, 1, "101" },
{0, 0, 0, 0, 0, 0}
};
@@ -92,7 +93,6 @@ int main(int argc, char *argv[])
trace::entering("main");
- bool verbose = options.is_set("verbose");
// Window size
unsigned w_1 = atoi(options.opt_value("win-size").c_str()); // Scale 1
@@ -105,11 +105,8 @@ int main(int argc, char *argv[])
binarization::internal::k3 = atof(options.opt_value("k3").c_str());
binarization::internal::k4 = atof(options.opt_value("k4").c_str());
-
- if (verbose)
- std::cout << "Using w_1=" << w_1 << " - s="
<< s << " - k="
- << k << " - min_ntrue=" << min_ntrue <<
std::endl;
-
+ scribo::debug::logger() << "Using w_1=" << w_1 << " -
s=" << s << " - k="
+ << k << " - min_ntrue=" << min_ntrue <<
std::endl;
Magick::InitializeMagick(0);
diff --git a/scribo/src/binarization/wolf.cc b/scribo/src/binarization/wolf.cc
index c481e09..4495f64 100644
--- a/scribo/src/binarization/wolf.cc
+++ b/scribo/src/binarization/wolf.cc
@@ -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.
@@ -58,7 +58,8 @@ static const scribo::debug::opt_data opt_desc[] =
{ "debug-prefix", "Enable debug image outputs. Prefix image name with
that "
"given prefix.", "<prefix>", 0, 1, 0 },
{ "k", "Wolf's formulae parameter", "<value>",
0, 1, "0.34" },
- { "verbose", "Enable verbose mode", 0, 0, 0, 0 },
+ { "verbose", "Enable verbose mode (mute, time, low, medium,
full)",
+ "<mode>", scribo::debug::check_verbose_mode, 1, "mute" },
{ "win-size", "Window size", "<size>", 0, 1,
"101" },
{0, 0, 0, 0, 0, 0}
};
@@ -85,12 +86,10 @@ int main(int argc, char *argv[])
trace::entering("main");
- bool verbose = options.is_set("verbose");
unsigned w = atoi(options.opt_value("win-size").c_str());
double k = atof(options.opt_value("k").c_str());
- if (verbose)
- std::cout << "Using w=" << w << " and k="
<< k << std::endl;
+ scribo::debug::logger() << "Using w=" << w << " and
k=" << k << std::endl;
image2d<value::rgb8> input;
io::magick::load(input, options.arg("input.*"));
--
1.7.2.5