def getRotateAngle(image):
    angle = 0
    newImage = image
    while not isVerticalRightLine(newImage):
        angle += ANGLE_STEP
        if angle >= 180:
            return 180
        newImage = rotateImage(image, angle)
        util.writeGrayIm("test_test.bmp", newImage)

    return angle
def getRotateAngle(image):
    angle = 0
    newImage = image
    while not isVerticalRightLine(newImage):
        angle += ANGLE_STEP
        if angle >= 180:
            return 180
        newImage = rotateImage(image, angle)
        util.writeGrayIm("test_test.bmp", newImage)

    return angle
        words = []
        for space in word_spaces:
            end = space[0]
            words.append(WordSpace(self.line, (start, end)))
            start = space[1]
        end = self.line.horizontal[1]
        words.append(WordSpace(self.line, (start, end)))
        return words


im = readGrayIm("../images/line_0.bmp")
im[im < 0.3] = 0
zone = sspace.Zone(im)
zone = xycuts.cut_edges(zone)
central_ind = sspace._central_ind(zone)
line = sspace.Line(zone.im, central_ind, horizontal=zone.horizontal, vertical=zone.vertical)
word_spaces = Splitter(line).find_word_spaces()
word_id = 0
output = "../output/"
rmtree(output)
mkdir(output)
for word_space in word_spaces:
    word = word_space.toWord()
    writeGrayIm(output + "word_%s.bmp" % word_id, word.extract())
    symbol_id = 0
    mkdir(output + "word_%s" % word_id)
    for symbol in word.symbols:
        writeGrayIm(output + "word_%s/symbol_%s.bmp" % (word_id, symbol_id), symbol.extract())
        symbol_id += 1
    word_id += 1
def splitDocumentLines(image):
    out = xy_cuts(image)
    for i in range(len(out)):
        fileLine = "../images/lines/line_" + str(i) + ".bmp"
        util.writeGrayIm(fileLine, out[i])
예제 #5
0
            start = space[1]
        end = self.line.horizontal[1]
        words.append(WordSpace(self.line, (start, end)))
        return words


im = readGrayIm("../images/line_0.bmp")
im[im < 0.3] = 0
zone = sspace.Zone(im)
zone = xycuts.cut_edges(zone)
central_ind = sspace._central_ind(zone)
line = sspace.Line(zone.im,
                   central_ind,
                   horizontal=zone.horizontal,
                   vertical=zone.vertical)
word_spaces = Splitter(line).find_word_spaces()
word_id = 0
output = "../output/"
rmtree(output)
mkdir(output)
for word_space in word_spaces:
    word = word_space.toWord()
    writeGrayIm(output + "word_%s.bmp" % word_id, word.extract())
    symbol_id = 0
    mkdir(output + "word_%s" % word_id)
    for symbol in word.symbols:
        writeGrayIm(output + "word_%s/symbol_%s.bmp" % (word_id, symbol_id),
                    symbol.extract())
        symbol_id += 1
    word_id += 1
def splitDocumentLines(image):
    out = xy_cuts(image)
    for i in range(len(out)):
        fileLine = "../images/lines/line_" + str(i) + ".bmp"
        util.writeGrayIm(fileLine, out[i])