def _compute_intensity(im, x, y):
    if ((x < 0).any() or (x >= im.shape[1]).any() or (y < 0).any() or (y >= im.shape[0]).any()):
        return inf
    p = set((p for p in zip(x, y)))
    score = 0
    for (j, i) in p:
        score += im[(i, j)]
    return (score / len(p))
def _compute_intensity(im, x, y):
    if ((x < 0).any() or (x >= im.shape[1]).any() or (y < 0).any() or (y >= im.shape[0]).any()):
        return inf
    p = set((p for p in zip(x, y)))
    score = 0
    for (j, i) in p:
        score += im[(i, j)]
    return (score / len(p))