예제 #1
0
def splitToSpaces(line):
    line = xycuts.cut_edges(line)
    central_ind = _central_ind(line)
    central_spaces = _find_central_spaces(line, central_ind)
    straight_spaces, other_spaces = _filter_straight_spaces(line, central_spaces)
    word_spaces, symbol_spaces = _filter_word_spaces(line, straight_spaces)
    return word_spaces, symbol_spaces, other_spaces
예제 #2
0
def doSplit(line):
    """split given zone (seems to be a line of text) and returns
    list of words each one interpreted"""
    line = xycuts.cut_edges(line)
    central_ind = _central_ind(line)
    central_spaces = _find_central_spaces(line, central_ind)
    straight_spaces, other_spaces = _filter_straight_spaces(line, central_spaces)
    word_spaces, symbol_spaces = _filter_word_spaces(line, straight_spaces)
    wry_slices = _filter_wry_spaces(line, central_ind, other_spaces)
    return _makeWords(line, word_spaces, symbol_spaces, wry_slices)
    def makeWords(self, word_spaces):
        start = self.line.horizontal[0]
        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
예제 #4
0
    def makeWords(self, word_spaces):
        start = self.line.horizontal[0]
        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)