diff --git a/pixelocr/page.py b/pixelocr/page.py index 6064fe1..fbf2cb5 100644 --- a/pixelocr/page.py +++ b/pixelocr/page.py @@ -101,9 +101,11 @@ class Line(PageObject): """Detect baseline height, relative to the top.""" bitmap = self.image.bitmap.astype(np.float) histogram = bitmap.sum(axis=1) - gradient = filters.correlate1d(histogram, [-1, 1], axis=0) + gradient = list(filters.correlate1d(histogram, [-1, 1], axis=0, mode='constant')) + gradient[0] = histogram[0] + gradient.append(-histogram[-1]) # top = gradient.argmax() - bottom = gradient.argmin() + bottom = np.argmin(gradient) return self.y + bottom @property