def plot_candidate_ends(im, wv, min_score, border=10):
    from pylab import plot, imshow, cm, ion, ioff, show, text
    (left, right) = group_ends(list(filter_ends(wv, min_score, im.shape, border)))
    ioff()
    m = {0: 'ro', (- 1): 'gs'}
    for (i, e) in enumerate(left):
        s = 0
        text(e.x[s], e.y[s], str(i), color=m[s][0])
        plot([e.x[s]], [e.y[s]], m[s])
    for (i, e) in enumerate(right):
        s = (- 1)
        text(e.x[s], e.y[s], str(i), color=m[s][0])
        plot([e.x[s]], [e.y[s]], m[s])
    show()
    ion()
def plot_candidate_ends(im, wv, min_score, border=10):
    from pylab import plot, imshow, cm, ion, ioff, show, text
    (left, right) = group_ends(list(filter_ends(wv, min_score, im.shape, border)))
    ioff()
    m = {0: 'ro', (- 1): 'gs'}
    for (i, e) in enumerate(left):
        s = 0
        text(e.x[s], e.y[s], str(i), color=m[s][0])
        plot([e.x[s]], [e.y[s]], m[s])
    for (i, e) in enumerate(right):
        s = (- 1)
        text(e.x[s], e.y[s], str(i), color=m[s][0])
        plot([e.x[s]], [e.y[s]], m[s])
    show()
    ion()