diff --git a/pixelocr/page.py b/pixelocr/page.py index 798187e..4b6982f 100644 --- a/pixelocr/page.py +++ b/pixelocr/page.py @@ -85,9 +85,9 @@ class PageObject(object): return self.image.fits(left, top, right, bottom) - def _optical_correction(self, other): - image1 = self.image - image2 = other.image + def _optical_correction(self, other, T=True): + image1 = self.image.T if T else self.image + image2 = other.image.T if T else other.image base = min(image1.top, image2.top) height = max(image1.bottom, image2.bottom) - base bitmap1 = np.hstack([np.ones((image1.height, 1)), image1.bitmap]) @@ -182,6 +182,10 @@ class Line(PageObject): mask = labels[blob_slice] != label return image.mask(mask) + def optical_distance(self, other): + distance = other.top - self.bottom + return distance + self._optical_correction(other, T=True) + class Glyph(PageObject): MIN_BODY_HEIGHT = 10