From 2012da79578872f0cc3c1de5397bd70e153c487d Mon Sep 17 00:00:00 2001 From: Andrey Golovizin Date: Fri, 8 Aug 2014 17:00:14 +0200 Subject: [PATCH] Clarify Image._iter_children() a little. --- pixelocr/image.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pixelocr/image.py b/pixelocr/image.py index 4c03c28..be70257 100644 --- a/pixelocr/image.py +++ b/pixelocr/image.py @@ -85,12 +85,17 @@ class Image(object): line_start = None prev_line_end = 0 + + def is_nonblank(row): + return row.any() + for i, row in enumerate(self.bitmap): - if row.any(): # non-blank row + if is_nonblank(row): if line_start is None: line_start = i - if line_start - prev_line_end >= min_space: - yield self.child_cls.space(line_start - prev_line_end, self.width) + height = line_start - prev_line_end + if height >= min_space: + yield self.child_cls.space(height, self.width) else: if line_start is not None: yield self.child_cls(self._data[line_start:i, :])