ocrd_cis/ocropy/ocrolib/morph.py
def propagate_labels_majority(image,labels):
    """Given an image and a set of labels, apply the labels
    to all the connected components in the image that overlap a label.
    For each component that has a conflict, select the label
    with the largest overlap."""
    rlabels,_ = label(image)
    cors = correspondences(rlabels,labels)
    outputs = zeros(amax(rlabels)+1,'i')
    counts = zeros(amax(rlabels)+1,'i')
    for rlabel, label_, count in cors.T:
        if not rlabel or not label_:
            # ignore background correspondences
            continue
        if counts[rlabel] < count:
            outputs[rlabel] = label_
            counts[rlabel] = count
    outputs[0] = 0
    return outputs[rlabels]
Given an image and a set of labels, apply the labels
    to all the connected components in the image that overlap a label.
    For each component that has a conflict, select the label
    with the largest overlap.
Given an image and a set of labels, apply the labels
to all the connected components in the image that overlap a label.
For each component that has a conflict, select the label
with the largest overlap.
Given an image and a set of labels apply the labels to all the connected components in the image that overlap a label . For each component that has a conflict select the label with the largest overlap .
def propagate_labels_majority(image,labels):
    rlabels,_ = label(image)
    cors = correspondences(rlabels,labels)
    outputs = zeros(amax(rlabels)+1,'i')
    counts = zeros(amax(rlabels)+1,'i')
    for rlabel, label_, count in cors.T:
        if not rlabel or not label_:
            continue
        if counts[rlabel] < count:
            outputs[rlabel] = label_
            counts[rlabel] = count
    outputs[0] = 0
    return outputs[rlabels]
def propagate_labels_majority ( image , labels ) : rlabels , _ = label ( image ) cors = correspondences ( rlabels , labels ) outputs = zeros ( amax ( rlabels ) + 1 , 'i' ) counts = zeros ( amax ( rlabels ) + 1 , 'i' ) for rlabel , label_ , count in cors . T : if not rlabel or not label_ : continue if counts [ rlabel ] < count : outputs [ rlabel ] = label_ counts [ rlabel ] = count outputs [ 0 ] = 0 return outputs [ rlabels ]
Given an image and a set of labels, apply the labels
to all the connected components in the image that overlap a label.
Given an image and a set of labels apply the labels to all the connected components in the image that overlap a label .
"""Given an image and a set of labels, apply the labels
    to all the connected components in the image that overlap a label.
    For each component that has a conflict, select the label
    with the largest overlap.""" # ignore background correspondences
image
labels