* src/debug/Makefile.am: Add new target.
* src/debug/center_pixel_stats.cc: New debug tool.
---
scribo/ChangeLog | 8 +++++
scribo/src/debug/Makefile.am | 2 +
scribo/src/debug/center_pixel_stats.cc | 52 ++++++++++++++++++++++++++++++++
3 files changed, 62 insertions(+), 0 deletions(-)
create mode 100644 scribo/src/debug/center_pixel_stats.cc
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 253021d..dc66eb2 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,13 @@
2010-11-15 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Add a new debug tool.
+
+ * src/debug/Makefile.am: Add new target.
+
+ * src/debug/center_pixel_stats.cc: New debug tool.
+
+2010-11-15 Guillaume Lazzara <z(a)lrde.epita.fr>
+
* scribo/canvas/integral_browsing.hh: Cleanup comments.
2010-11-15 Guillaume Lazzara <z(a)lrde.epita.fr>
diff --git a/scribo/src/debug/Makefile.am b/scribo/src/debug/Makefile.am
index d203f5c..e236dc4 100644
--- a/scribo/src/debug/Makefile.am
+++ b/scribo/src/debug/Makefile.am
@@ -18,6 +18,7 @@
include $(top_srcdir)/scribo/scribo.mk
noinst_PROGRAMS = \
+ center_pixel_stats \
show_info_x_height \
show_info_median_inter_characters \
show_links_left_right_links_validation \
@@ -46,6 +47,7 @@ noinst_PROGRAMS = \
show_objects_thin
+center_pixel_stats_SOURCES = center_pixel_stats.cc
show_info_x_height_SOURCES = show_info_x_height.cc
show_info_median_inter_characters_SOURCES = show_info_median_inter_characters.cc
show_links_left_right_links_validation_SOURCES =
show_links_left_right_links_validation.cc
diff --git a/scribo/src/debug/center_pixel_stats.cc
b/scribo/src/debug/center_pixel_stats.cc
new file mode 100644
index 0000000..c9d154d
--- /dev/null
+++ b/scribo/src/debug/center_pixel_stats.cc
@@ -0,0 +1,52 @@
+#include <mln/core/image/image2d.hh>
+#include <mln/accu/stat/deviation.hh>
+#include <mln/accu/stat/mean.hh>
+#include <mln/accu/pair.hh>
+#include <mln/data/compute.hh>
+#include <mln/io/pgm/load.hh>
+
+#include <scribo/binarization/sauvola_threshold_image.hh>
+
+#include <scribo/debug/usage.hh>
+
+
+const char *args_desc[][2] =
+{
+ { "input.pgm", "A graylevel image." },
+ {0, 0}
+};
+
+
+
+int main(int argc, char *argv[])
+{
+ using namespace mln;
+ using namespace scribo::binarization::internal;
+
+ if (argc != 2)
+ return scribo::debug::usage(argv,
+ "Give statistics for the center pixel "
+ "of an image. The whole image is considered "
+ "as a window centered to that pixel.",
+ "input.* input.pgm",
+ args_desc);
+
+ typedef value::int_u8 V;
+ image2d<V> input;
+ io::pgm::load(input, argv[1]);
+
+ typedef accu::stat::deviation<V> dev_t;
+ typedef accu::stat::mean<V> mean_t;
+
+ float mean = data::compute(mean_t(), input);
+ dev_t dev(mean);
+ float stddev = data::compute(dev, input);
+
+ std::cout << "mean = " << mean
+ << " - stddev = " << stddev
+ << std::endl;
+ std::cout << "center = " << input.domain().pcenter()
+ << " - threshold = "
+ << sauvola_threshold_formula(mean, stddev, 0.34, 128)
+ << std::endl;
+}
--
1.5.6.5
Show replies by date