[Image-SIG] Choosing arbitrary polygons
Fri, 19 Apr 2002 10:34:20 -0500
> One of the most important things that I need
>to do is to select arbitrary areas of an image (polygons), and then
>extract statistics off that.
Here is some code that should give you some ideas
def PolygonHistogram(anImage, aPolygon):
'''computes the histogram of the portion of anImage within
mask = Image.new('1', anImage.size, 0)
draw = ImageDraw.Draw(mask)
draw.polygon(aPolygon, fill=1, outline=1)
You can also do interesting things by using various ImageChops
operations on an image and a mask.