def fill_color_polygon(image, polygon, color, alpha=0.5):
    """Color interior of polygon with alpha-blending. This function modified input in place.
    """
    _mask = Image.new('L', (image.shape[1], image.shape[0]), 0)
    ImageDraw.Draw(_mask).polygon(polygon, outline=1, fill=1)
    mask = np.array(_mask, np.bool)
    for c in range(3):
        channel = image[:, :, c]
        channel[mask] = channel[mask] * (1. - alpha) + color[c] * alpha
Color interior of polygon with alpha-blending. This function modified input in place.
    
tridet/utils/visualization.py