
* binarization/sauvola_ms.hh: Add a missing include. * binarization/sauvola_threshold.hh: Remove debug and useless comments. * preprocessing/unskew.hh: Fix invalid guards. * primitive/extract/components.hh: Fill image extension. * primitive/extract/lines_pattern.hh: Adjust and fill image extension. * primitive/extract/lines_v_thick.hh: Fix traces. --- scribo/ChangeLog | 18 ++++++++++++++ scribo/binarization/sauvola_ms.hh | 4 +++ scribo/binarization/sauvola_threshold.hh | 37 ++++++---------------------- scribo/preprocessing/unskew.hh | 6 ++-- scribo/primitive/extract/components.hh | 7 ++++- scribo/primitive/extract/lines_pattern.hh | 23 +++++++++++------- scribo/primitive/extract/lines_v_thick.hh | 4 +- 7 files changed, 55 insertions(+), 44 deletions(-) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index 8b4c4d7..97eb271 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,5 +1,23 @@ 2010-03-11 Guillaume Lazzara <z@lrde.epita.fr> + Small fixes. + + * binarization/sauvola_ms.hh: Add a missing include. + + * binarization/sauvola_threshold.hh: Remove debug and useless + comments. + + * preprocessing/unskew.hh: Fix invalid guards. + + * primitive/extract/components.hh: Fill image extension. + + * primitive/extract/lines_pattern.hh: Adjust and fill image + extension. + + * primitive/extract/lines_v_thick.hh: Fix traces. + +2010-03-11 Guillaume Lazzara <z@lrde.epita.fr> + Add new preprocessing routines. * preprocessing/denoise.hh, diff --git a/scribo/binarization/sauvola_ms.hh b/scribo/binarization/sauvola_ms.hh index 858a1d3..7bbd9f8 100644 --- a/scribo/binarization/sauvola_ms.hh +++ b/scribo/binarization/sauvola_ms.hh @@ -40,6 +40,8 @@ # include <mln/core/box_runend_piter.hh> +# include <mln/util/couple.hh> + # include <scribo/subsampling/integral_single_image.hh> # include <scribo/core/macros.hh> @@ -63,6 +65,8 @@ namespace scribo namespace internal { + using namespace mln; + template <typename V> V my_find_root(image2d<V>& parent, const V& x) { diff --git a/scribo/binarization/sauvola_threshold.hh b/scribo/binarization/sauvola_threshold.hh index 01bd1b0..940b7cd 100644 --- a/scribo/binarization/sauvola_threshold.hh +++ b/scribo/binarization/sauvola_threshold.hh @@ -46,6 +46,8 @@ # include <mln/fun/v2v/rgb_to_int_u.hh> +# include <mln/debug/println.hh> + # include <scribo/core/init_integral_image.hh> namespace scribo @@ -187,38 +189,9 @@ namespace scribo double s_x_y = std::sqrt((s_x_y_tmp - (m_x_y_tmp * m_x_y_tmp) / wh) / (wh - 1.f)); - -// if (p == point2d(3,3))// || p == point2d(4,4) || p == point2d(1,1)) -// { -// // std::cout << "p" << p << " - A(" << row_min << ", " << col_min -// // << ") = " << simple.at_(row_min, col_min) - -// << " - B(" << row_min << ", " << col_max -// << ") = " << simple.at_(row_min, col_max) - -// << " - C(" << row_max << ", " << col_min -// << ") = " << simple.at_(row_max, col_min) - -// << " - D(" << row_max << ", " << col_max -// << ") = " << simple.at_(row_max, col_max) -// << " - n = " << wh -// << std::endl; - -// << std::endl; -// } - // Thresholding. double t_x_y = sauvola_threshold_formula(m_x_y, s_x_y, k, R); - -// std::cout << p -// << " - m = " << m_x_y -// << " - s = " << s_x_y -// << " - t = " << t_x_y -// << " - sum = " << m_x_y_tmp -// << " - sum_2 = " << s_x_y_tmp -// << std::endl; - return t_x_y; } @@ -487,6 +460,12 @@ namespace scribo simple = init_integral_image(input, scribo::internal::identity_), squared = init_integral_image(input, scribo::internal::square_); +// debug::println(input); +// std::cout << "============" << std::endl; +// // debug::println(simple); +// // std::cout << "============" << std::endl; +// // debug::println(squared); + return sauvola_threshold(input, window_size, simple, squared); } diff --git a/scribo/preprocessing/unskew.hh b/scribo/preprocessing/unskew.hh index 3b90d8a..a01cae3 100644 --- a/scribo/preprocessing/unskew.hh +++ b/scribo/preprocessing/unskew.hh @@ -23,8 +23,8 @@ // exception does not however invalidate any other reasons why the // executable file might be covered by the GNU General Public License. -#ifndef SCRIBO_UNSKEW_HOUGH_HH -# define SCRIBO_UNSKEW_HOUGH_HH +#ifndef SCRIBO_PREPROCESSING_UNSKEW_HH +# define SCRIBO_PREPROCESSING_UNSKEW_HH /// \file /// @@ -112,4 +112,4 @@ namespace scribo } // end of namespace mln -# endif // SCRIBO_UNSKEW_HOUGH_HH +# endif // SCRIBO_PREPROCESSING_UNSKEW_HH diff --git a/scribo/primitive/extract/components.hh b/scribo/primitive/extract/components.hh index f13904f..3363331 100644 --- a/scribo/primitive/extract/components.hh +++ b/scribo/primitive/extract/components.hh @@ -43,6 +43,8 @@ # include <mln/util/array.hh> +# include <mln/extension/fill.hh> + # include <scribo/core/component_set.hh> @@ -88,7 +90,7 @@ namespace scribo const Neighborhood<N>& nbh, V& ncomponents) { mlc_equal(mln_value(I),bool)::check(); - mlc_is_a(V, mln::value::Symbolic)::check(); +// mlc_is_a(V, mln::value::Symbolic)::check(); mln_precondition(exact(input).is_valid()); mln_precondition(exact(nbh).is_valid()); (void) input; @@ -115,6 +117,9 @@ namespace scribo typedef mln::accu::center<mln_site(L)> center_accu_t; typedef mln::accu::pair<bbox_accu_t, center_accu_t> pair_accu_t; + // Setting extension value. + extension::fill(input, 0); + util::couple<L, util::couple<util::array<mln_result(pair_accu_t)>, util::array<pair_accu_t> > > diff --git a/scribo/primitive/extract/lines_pattern.hh b/scribo/primitive/extract/lines_pattern.hh index 57958ec..18cb784 100644 --- a/scribo/primitive/extract/lines_pattern.hh +++ b/scribo/primitive/extract/lines_pattern.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -36,6 +37,8 @@ # include <mln/core/alias/window2d.hh> # include <mln/core/routine/duplicate.hh> +# include <mln/extension/adjust_fill.hh> + # include <mln/accu/transform_line.hh> # include <mln/accu/count_value.hh> @@ -77,13 +80,16 @@ namespace scribo lines_pattern(const Image<I>& input_, unsigned length, unsigned dir, const Window<W>& win_) { - trace::entering("mln::lines_pattern"); + trace::entering("scribo::primitive::extract::lines_pattern"); const I& input = exact(input_); const W& win = exact(win_); mlc_is(mln_value(I), bool)::check(); mln_precondition(input.is_valid()); + // Adjusting extension. + extension::adjust_fill(input, length / 2, 0); + accu::count_value<bool> accu(true); mln_ch_value(I,unsigned) tmp = accu::transform_line(accu, input, length, dir); @@ -100,18 +106,18 @@ namespace scribo // If the foreground part of the pattern has more than 20% // of background pixels, the current pixel is considered as // background pixel. - if (length - tmp(p) > (0.2f * length)) + if (length - tmp(p) > unsigned(0.2f * length) + 1) { output(p) = false; continue; } - // If the background parts of the pattern have less than 95% - // of foreground pixels, the current pixel is considered as - // part of the background. + // If the background parts of the pattern have exactly or + // less than 95% of background pixels, the current pixel is + // considered as part of the background. is_foreground = true; for_all(q) - if ((length - tmp(q)) < (length * 0.95f)) + if ((length - tmp(q)) < unsigned(length * 0.95f) + 1) { is_foreground = false; break; @@ -120,8 +126,7 @@ namespace scribo output(p) = is_foreground; } - - trace::exiting("mln::lines_pattern"); + trace::exiting("scribo::primitive::extract::lines_pattern"); return output; } diff --git a/scribo/primitive/extract/lines_v_thick.hh b/scribo/primitive/extract/lines_v_thick.hh index e1cecee..2ee09dd 100644 --- a/scribo/primitive/extract/lines_v_thick.hh +++ b/scribo/primitive/extract/lines_v_thick.hh @@ -104,7 +104,7 @@ namespace scribo const Neighborhood<N>& nbh, V& nlines, unsigned line_length) { - trace::entering("scribo::primitive::lines_v_thick"); + trace::entering("scribo::primitive::extract::lines_v_thick"); internal::lines_v_thick_tests(input, nbh, nlines, line_length); @@ -114,7 +114,7 @@ namespace scribo object_image(mln_ch_value(I,V)) output = lines_thick(input, nbh, nlines, win); - trace::exiting("scribo::primitive::lines_v_thick"); + trace::exiting("scribo::primitive::extract::lines_v_thick"); return output; } -- 1.5.6.5