Say I have an image in PIL
from PIL import Image
Image.open(path_to_my_image)
and two lists of x points and y points
x = ['10', '30', '70']
y = ['15', '45', '90']
Is there a way to overlay my polygon with transparency on this image?
Also, is PIL a good library for this? Or should I use a different one? (e.g. scikits.image, or render in an image with pylab).
PIL is a fine tool for this:
The call signature for
draw.polygonis:so the only options are
fillandoutline. I looked at the source code to find this information.IPython told me:
which showed me where to look.
To draw a semi-transparent polygon on top of
img, make a copy of the image. One the copy, draw the polygon in full color without alpha. Then use Image.blend to combine the original image with the copy with a set level ofalpha. For each pixel: