Make baseline be exactly _below_ the letter.
The letter now "sits" on the baseline. This is to make indexing more convenient.
This commit is contained in:
parent
3d2b2ba30a
commit
e3217d28b8
2 changed files with 2 additions and 2 deletions
|
|
@ -68,7 +68,7 @@ class PageScene(QGraphicsScene):
|
||||||
for letter in word:
|
for letter in word:
|
||||||
if not letter.image.isspace:
|
if not letter.image.isspace:
|
||||||
self.addRect(letter.x1, letter.y1, letter.width - 1, letter.height - 1, letterPen, letterBrush)
|
self.addRect(letter.x1, letter.y1, letter.width - 1, letter.height - 1, letterPen, letterBrush)
|
||||||
self.addLine(line.x1, line.y1 + line.baseline, line.x2, line.y1 + line.baseline, linePen)
|
self.addLine(line.x1, line.y1 + line.baseline, line.x2, line.y1 + line.baseline - 1, linePen)
|
||||||
# self.addRect(line.x1, line.y1, line.width, line.height, Qt.red)
|
# self.addRect(line.x1, line.y1, line.width, line.height, Qt.red)
|
||||||
|
|
||||||
def addPage(self, page):
|
def addPage(self, page):
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ class Line(PageObject):
|
||||||
"""Detect baseline height, relative to the top."""
|
"""Detect baseline height, relative to the top."""
|
||||||
bitmap = self.image.bitmap.astype(np.float)
|
bitmap = self.image.bitmap.astype(np.float)
|
||||||
histogram = bitmap.sum(axis=1)
|
histogram = bitmap.sum(axis=1)
|
||||||
gradient = filters.convolve1d(histogram, [1, -1], axis=0)
|
gradient = filters.correlate1d(histogram, [-1, 1], axis=0)
|
||||||
# top = gradient.argmax()
|
# top = gradient.argmax()
|
||||||
bottom = gradient.argmin()
|
bottom = gradient.argmin()
|
||||||
return bottom
|
return bottom
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue