I'd like to use PIL to rasterise a polygon, but I'm having trouble getting even
a simple test to work. I expect the following to produce a 11x11 array with a
white diamond on a black background, but I only get the background.
diamond = array([[5,0], [10,5], [5,10], [0,5]])
img = Image.new('L', (11,11), 0)
draw = ImageDraw.Draw(img)
draw.polygon(diamond, fill=1, outline=1)
array(img)
array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=uint8)
The method draw.line() works as it should. What am I doing wrong?
Thanks,
-AM
_______________________________________________
Image-SIG maillist - [email protected]
http://mail.python.org/mailman/listinfo/image-sig