ocrd_cis/ocropy/common.py
def finalize():
            """Assign current line labels into new region, and re-order them inside."""
            nonlocal num_regions
            nonlocal relabel
            linelabels = np.setdiff1d(np.unique(lbin), [0])
            if debug: LOG.debug('checking line labels %s for conflicts', str(linelabels))
            # when there is a conflict for a line label, assign (or keep) the more frequent region label
            linelabels = [label
                          for label in linelabels
                          if (not relabel[label] or
                              np.count_nonzero(lbin == label) > 0.5 * bincounts[label])]
            if not linelabels:
                return
            num_regions += 1
            if debug: LOG.debug('new region {} for lines {}'.format(num_regions, linelabels))
            else:
                LOG.debug('new region %d for %d lines', num_regions, len(linelabels))
            relabel[linelabels] = num_regions
Assign current line labels into new region, and re-order them inside.
Assign current line labels into new region, and re-order them inside.
Assign current line labels into new region and re - order them inside .
def finalize():
            nonlocal num_regions
            nonlocal relabel
            linelabels = np.setdiff1d(np.unique(lbin), [0])
            if debug: LOG.debug('checking line labels %s for conflicts', str(linelabels))
            linelabels = [label
                          for label in linelabels
                          if (not relabel[label] or
                              np.count_nonzero(lbin == label) > 0.5 * bincounts[label])]
            if not linelabels:
                return
            num_regions += 1
            if debug: LOG.debug('new region {} for lines {}'.format(num_regions, linelabels))
            else:
                LOG.debug('new region %d for %d lines', num_regions, len(linelabels))
            relabel[linelabels] = num_regions
def finalize ( ) : nonlocal num_regions nonlocal relabel linelabels = np . setdiff1d ( np . unique ( lbin ) , [ 0 ] ) if debug : LOG . debug ( 'checking line labels %s for conflicts' , str ( linelabels ) ) linelabels = [ label for label in linelabels if ( not relabel [ label ] or np . count_nonzero ( lbin == label ) > 0.5 * bincounts [ label ] ) ] if not linelabels : return num_regions += 1 if debug : LOG . debug ( 'new region {} for lines {}' . format ( num_regions , linelabels ) ) else : LOG . debug ( 'new region %d for %d lines' , num_regions , len ( linelabels ) ) relabel [ linelabels ] = num_regions
Assign current line labels into new region, and re-order them inside.
Assign current line labels into new region and re - order them inside .
"""Assign current line labels into new region, and re-order them inside.""" # when there is a conflict for a line label, assign (or keep) the more frequent region label