Add Line.optical_distance().
This commit is contained in:
parent
91f24da142
commit
22f5c5e2b1
1 changed files with 7 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue