How do you rasterize an ellipse from an axis-aligned box?
ellipse draws an oval inscribed in the supplied bounding rectangle. Its corners generally lie outside the oval.
Pixel experiment and interpretation
Probe the center and top-left corner of a circular field-of-view mask. A rectangular substitute incorrectly keeps the corner background.
from PIL import Image, ImageDraw
im=Image.new('L',(7,7))
ImageDraw.Draw(im).ellipse((0,0,6,6),fill=1)
(im.getpixel((3,3)),im.getpixel((0,0)))Result (1, 0)
中文
怎样从轴对齐边界框栅格化椭圆?
ellipse 在给定矩形内绘制椭圆,矩形角点通常位于椭圆之外。
像素实验与适用边界
做圆形视野掩膜时检查中心和左上角。用矩形代替椭圆会错误保留四角的背景。
from PIL import Image, ImageDraw
im=Image.new('L',(7,7))
ImageDraw.Draw(im).ellipse((0,0,6,6),fill=1)
(im.getpixel((3,3)),im.getpixel((0,0)))结果 (1, 0)