* scribo/binarization/sauvola_ms.hh: remove tests on window size.
* scribo/canvas/integral_browsing.hh: Check window size.
---
scribo/ChangeLog | 8 ++++++++
scribo/scribo/binarization/sauvola_ms.hh | 28 ----------------------------
scribo/scribo/canvas/integral_browsing.hh | 19 +++++++++++++++++++
3 files changed, 27 insertions(+), 28 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 1c1295b..5d67d59 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,13 @@
2012-08-23 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Make integral browsing canvas robust to large windows.
+
+ * scribo/binarization/sauvola_ms.hh: remove tests on window size.
+
+ * scribo/canvas/integral_browsing.hh: Check window size.
+
+2012-08-23 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Several small fixes.
* scribo/estim/font_color.hh: Fix namespace ambiguities.
diff --git a/scribo/scribo/binarization/sauvola_ms.hh
b/scribo/scribo/binarization/sauvola_ms.hh
index ba58207..5f0f963 100644
--- a/scribo/scribo/binarization/sauvola_ms.hh
+++ b/scribo/scribo/binarization/sauvola_ms.hh
@@ -169,34 +169,6 @@ 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;
-
- // Make sure the window fits in the image domain.
- if (w_local_w >= static_cast<const unsigned>(integral_sum_sum_2.ncols()))
- {
- w_local_w = std::min(integral_sum_sum_2.ncols(),
- integral_sum_sum_2.nrows()) - integral_sum_sum_2.border();
- w_local_h = w_local_w;
- trace::warning("integral_browsing - Adjusting window width since it"
- " was larger than image width.");
- }
- if (w_local_h >= static_cast<const unsigned>(integral_sum_sum_2.nrows()))
- {
- w_local_h = std::min(integral_sum_sum_2.nrows(),
- integral_sum_sum_2.ncols()) - integral_sum_sum_2.border();
- w_local_w = w_local_h;
- trace::warning("integral_browsing - Adjusting window height since it"
- " was larger than image height.");
- }
-
- if (! (w_local % 2))
- {
- --w_local_w;
- ++w_local_h;
- }
-
- //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> >
f(sub, K, SCRIBO_DEFAULT_SAUVOLA_R, e_2, i, q);
diff --git a/scribo/scribo/canvas/integral_browsing.hh
b/scribo/scribo/canvas/integral_browsing.hh
index da13fe7..5328a5a 100644
--- a/scribo/scribo/canvas/integral_browsing.hh
+++ b/scribo/scribo/canvas/integral_browsing.hh
@@ -88,6 +88,25 @@ namespace scribo
// mln_precondition((h/2) < ima.nrows());
// mln_precondition((w/2) < ima.ncols());
+ // Adjust window size to image.
+ if (w > (ima.domain().ncols() - ima.border()))
+ {
+ w = std::min(ima.domain().ncols(), ima.domain().nrows()) - ima.border();
+ if (! (w % 2))
+ --w;
+ trace::warning("integral_browsing - Adjusting window width since it"
+ " was larger than image height.");
+ }
+ if (h > (ima.domain().nrows() - ima.border()))
+ {
+ h = std::min(ima.domain().ncols(), ima.domain().nrows()) - ima.border();
+ if (! (h % 2))
+ --h;
+ trace::warning("integral_browsing - Adjusting window height since it"
+ " was larger than image width.");
+ }
+
+
const int
nrows = ima.nrows(),
ncols = ima.ncols(),
--
1.7.2.5