ocrd_cis/ocropy/ocrolib/morph.py
def keep_marked(image,markers):
    """Given a marker image, keep only the connected components
    that overlap the markers."""
    labels,_ = label(image)
    marked = unique(labels*(markers!=0))
    kept = in1d(labels.ravel(),marked)
    return (image!=0)*kept.reshape(*labels.shape)
Given a marker image, keep only the connected components
    that overlap the markers.
Given a marker image, keep only the connected components
that overlap the markers.
Given a marker image keep only the connected components that overlap the markers .
def keep_marked(image,markers):
    labels,_ = label(image)
    marked = unique(labels*(markers!=0))
    kept = in1d(labels.ravel(),marked)
    return (image!=0)*kept.reshape(*labels.shape)
def keep_marked ( image , markers ) : labels , _ = label ( image ) marked = unique ( labels * ( markers != 0 ) ) kept = in1d ( labels . ravel ( ) , marked ) return ( image != 0 ) * kept . reshape ( * labels . shape )
Given a marker image, keep only the connected components
that overlap the markers.
Given a marker image keep only the connected components that overlap the markers .
"""Given a marker image, keep only the connected components
    that overlap the markers."""
image
markers