[Image-SIG] Troubles with ellipses
Joe Reinhardt
jmr@everest.radiology.uiowa.edu
05 Feb 2000 22:16:01 -0600
--=-=-=
I am trying to draw an ellipse onto a PIL canvas. I wasn't able to
find much documentation on the ImageDraw.ellipse method, but I think I
properly determined the order of arguments to specify the major and
minor axes. My trouble is that one of the axes is coming out a bit
too short.
Attached below is an example. I was expecting to see an ellipse
exactly inscribing the rectangle. However, the bottom edge is off by
one pixel.
Any ideas?
--=-=-=
Content-Type: application/octet-stream
Content-Disposition: attachment; filename=el.py
Content-Description: Ellipse test code
#
# ellipse test
#
import Image, ImageDraw
size = 255
r1 = 40
r2 = 55
center = (size - 1)/2
im = Image.new("L", (size, size))
draw = ImageDraw.Draw(im)
print "center = " + `center`
print `[center - r1, center - r2, center + r1, center + r2]`
draw.rectangle([center - r1, center - r2,
center + r1, center + r2], 255)
draw.ellipse([center - r1, center - r2,
center + r1, center + r2], 150)
im.show()
--=-=-=
--
Joseph M. Reinhardt joe-reinhardt@uiowa.edu
Department of Biomedical Engineering 1402 Seamans Center
University of Iowa Iowa City, IA 52242
Phone: 319-335-5634 Fax: 319-335-5631
--=-=-=--