diff --git a/pixelocr/page.py b/pixelocr/page.py index 13c9f9c..94bc62d 100644 --- a/pixelocr/page.py +++ b/pixelocr/page.py @@ -159,14 +159,15 @@ class Line(PageObject): @cached_property def baseline(self): """Detect baseline height, relative to the top.""" - bitmap = self.image.bitmap + skip = self.height // 2 + bitmap = self.image.bitmap[skip:, :] bitmap = grey_closing(bitmap, (0, 10), mode='constant') histogram = bitmap.sum(axis=1) gradient = list(filters.correlate1d(histogram, [-1, 1], axis=0, mode='constant')) gradient[0] = histogram[0] gradient.append(-histogram[-1]) # top = gradient.argmax() - bottom = np.argmin(gradient) + bottom = np.argmin(gradient) + skip return self.y + bottom @property