olena-2.0-109-g75b5aa1 Make use of logger features.

* scribo/binarization/internal/local_threshold_core.hh, * scribo/binarization/internal/sauvola_formula.hh, * scribo/binarization/sauvola_ms.hh: Make use of operator<< with debug::logger. --- scribo/ChangeLog | 9 ++++ .../binarization/internal/local_threshold_core.hh | 16 +++---- .../binarization/internal/sauvola_formula.hh | 18 +-------- scribo/scribo/binarization/sauvola_ms.hh | 40 +++++++++----------- 4 files changed, 36 insertions(+), 47 deletions(-) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index 114ec97..f70d0cc 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,3 +1,12 @@ +2012-05-11 Guillaume Lazzara <z@lrde.epita.fr> + + Make use of logger features. + + * scribo/binarization/internal/local_threshold_core.hh, + * scribo/binarization/internal/sauvola_formula.hh, + * scribo/binarization/sauvola_ms.hh: Make use of operator<< with + debug::logger. + 2012-08-23 Guillaume Lazzara <z@lrde.epita.fr> * src/binarization/sauvola_ms.cc: Fix options handling. diff --git a/scribo/scribo/binarization/internal/local_threshold_core.hh b/scribo/scribo/binarization/internal/local_threshold_core.hh index 7979da3..7589499 100644 --- a/scribo/scribo/binarization/internal/local_threshold_core.hh +++ b/scribo/scribo/binarization/internal/local_threshold_core.hh @@ -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. // @@ -51,7 +52,6 @@ # include <mln/debug/filename.hh> # endif // ! SCRIBO_LOCAL_THRESHOLD_DEBUG -# include <mln/util/timer.hh> namespace scribo { @@ -122,8 +122,7 @@ namespace scribo trace::entering("scribo::binarization::internal::impl::generic::local_threshold_core"); mln_precondition(exact(input).is_valid()); - mln::util::timer t; - t.start(); + scribo::debug::logger().start_local_time_logging(); // Make sure the image sizes are a multiple of 3 in each // dimension. (browsing while binarizing relies on that @@ -140,8 +139,7 @@ namespace scribo sub_domains[2].first(), sub_domains[2].second()); - t.stop(); - std::cout << "image integrale - " << t << std::endl; + scribo::debug::logger().stop_local_time_logging("image integrale -"); # ifdef SCRIBO_LOCAL_THRESHOLD_DEBUG initialize(internal::debug_mean, input); @@ -152,7 +150,7 @@ namespace scribo initialize(internal::debug_alphacond, input); # endif // ! SCRIBO_LOCAL_THRESHOLD_DEBUG - t.restart(); + scribo::debug::logger().start_local_time_logging(); window_size /= 3; if (window_size % 2) @@ -162,8 +160,8 @@ namespace scribo scribo::canvas::integral_browsing(integral, 1, window_size, window_size, 3, f); - t.stop(); - std::cout << "Binarization - " << t << std::endl; + + scribo::debug::logger().stop_local_time_logging("Binarization -"); trace::exiting("scribo::binarization::internal::impl::generic::local_threshold_core"); } diff --git a/scribo/scribo/binarization/internal/sauvola_formula.hh b/scribo/scribo/binarization/internal/sauvola_formula.hh index a06d6f9..005c034 100644 --- a/scribo/scribo/binarization/internal/sauvola_formula.hh +++ b/scribo/scribo/binarization/internal/sauvola_formula.hh @@ -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. // @@ -48,8 +49,6 @@ #include <mln/core/alias/point2d.hh> -// extern mln::image2d<bool> skewness_pbm; - namespace scribo { @@ -89,25 +88,12 @@ namespace scribo # ifndef MLN_INCLUDE_ONLY - // bool b; - // double skewness_; - inline double sauvola_formula::operator()(const double m_x_y, const double s_x_y, const double K, const double R) const { - // if (b) - // std::cout << skewness_ << " - " << (K * -1 * skewness_) << std::endl; - // volatile double new_t = ((skewness_ < 0) ? -skewness_ : 1 * m_x_y * (1.0 + K * ((s_x_y / R) - 1.0))); - // volatile double old_t = (m_x_y * (1.0 + K * ((s_x_y / R) - 1.0))); - // if (skewness_ > 0) - // if (new_t != old_t) - // std::cout << skewness_ << " - " << new_t << " vs " << old_t << std::endl; - // if (skewness_pbm(p)) return m_x_y * (1.0 + K * ((s_x_y / R) - 1.0)); - // else - // return (255 - m_x_y) * (1.0 + K * ((s_x_y / R) - 1.0)); } inline diff --git a/scribo/scribo/binarization/sauvola_ms.hh b/scribo/scribo/binarization/sauvola_ms.hh index 3d04629..b1e8144 100644 --- a/scribo/scribo/binarization/sauvola_ms.hh +++ b/scribo/scribo/binarization/sauvola_ms.hh @@ -78,7 +78,6 @@ # include <mln/accu/math/count.hh> # endif // ! SCRIBO_LOCAL_THRESHOLD_DEBUG -# include <mln/util/timer.hh> namespace scribo { @@ -838,8 +837,7 @@ namespace scribo typedef image2d<mln::util::couple<double,double> > integral_t; // integral_t integral_sum_sum_2; - mln::util::timer t; - t.start(); + scribo::debug::logger().start_local_time_logging(); // Subsampling from scale 1 to 2. { @@ -852,9 +850,8 @@ namespace scribo sub_ima.append(fi.sub); } - t.stop(); - std::cout << "1. subsampling and integral - " << t << std::endl; - t.restart(); + scribo::debug::logger().stop_local_time_logging("1. subsampling and integral -"); + scribo::debug::logger().start_local_time_logging(); // Subsampling to scale 3 and 4. // @@ -865,9 +862,8 @@ namespace scribo sub_domains[i].first(), sub_domains[i].second())); - t.stop(); - std::cout << "2. More subsampling - " << t << std::endl; - t.restart(); + scribo::debug::logger().stop_local_time_logging("2. More subsampling -"); + scribo::debug::logger().start_local_time_logging(); // Compute threshold images. image2d<int_u8> e_2; @@ -951,9 +947,8 @@ namespace scribo K); } - t.stop(); - std::cout << "3. Multi-scale processing - " << t << std::endl; - t.restart(); + scribo::debug::logger().stop_local_time_logging("3. Multi-scale processing -"); + scribo::debug::logger().start_local_time_logging(); # ifdef SCRIBO_LOCAL_THRESHOLD_DEBUG @@ -965,9 +960,8 @@ namespace scribo // Propagate scale values. e_2 = transform::influence_zone_geodesic(e_2, c8()); - t.stop(); - std::cout << "4. Influence Zone on Scale image - " << t << std::endl; - t.restart(); + scribo::debug::logger().stop_local_time_logging("4. Influence Zone on Scale image -"); + scribo::debug::logger().start_local_time_logging(); # ifdef SCRIBO_LOCAL_THRESHOLD_DEBUG @@ -980,10 +974,13 @@ namespace scribo mln::util::array<unsigned> count = labeling::compute(accu::meta::math::count(), e_2, 4); unsigned npixels = e_2.domain().nsites(); - std::cout << "Scale ratios: 2 (" << count[2] / (float)npixels * 100 - << ") - 3 (" << count[3] / (float)npixels * 100 - << ") - 4 (" << count[4] / (float)npixels * 100 << ")" - << std::endl; + scribo::debug::logger() << "Scale ratios: 2 (" + << count[2] / (float)npixels * 100 + << ") - 3 (" + << count[3] / (float)npixels * 100 + << ") - 4 (" + << count[4] / (float)npixels * 100 << ")" + << std::endl; if (internal::scale_proba_output) io::dump::save(internal::debug_scale_proba, @@ -994,9 +991,8 @@ namespace scribo image2d<bool> output = internal::multi_scale_binarization(input_1, e_2, t_ima, s); - t.stop(); - std::cout << "5. Final binarization - " << t << std::endl; - t.restart(); + scribo::debug::logger().stop_local_time_logging("5. Final binarization -"); + scribo::debug::logger().start_local_time_logging(); trace::exiting("scribo::binarization::sauvola_ms"); return output; -- 1.7.2.5
participants (1)
-
Guillaume Lazzara