[Image-SIG] antialiasing in pil -2
Mon, 14 May 2001 08:54:14 -0600
The sample code you provide doesn't really perform anti-aliasing as I had
suggested... try something like this instead, and it will probably give you
a better/smoother result:
# create the ORIGINAL image at scale* resolution, don't size up an
# this way, you have finer detail that will result in smoother
im = create_im(scale*dxy, scale*dxy)
im = create_im(dxy, dxy, scale)
im = im.resize((dxy), Image.BICUBIC)
def create_im (width, height, scale=1):
im = Image.new(width, height)
object_size = object_size*scale
# draw your objects...
Not much of a change above, but rendering all your data at scale*
resolution then scaling down with BICUBIC will create much smoother results
than scaling up using NEAREST then scaling down with BICUBIC. The latter
will work, but will provide minimal anti-aliasing.
As for 1-pixel wide lines... if they're rendered at scale* the width you
want them to be when they're done, they'll be "OK", but 1-pixel
anti-aliased lines will always fade in/out. I'd suggest that you set
1-pixel lines to be something like 1.5 pixels so that they show up better.
At 4* res, that would be 6 pixels wide. I'm not sure how you'd set the
line width in Imagedraw, I've never tried it.
Drongelen / To: Kevin.Cazabon@gretag.com
VisualSpace cc: email@example.com
<kees@visuals Subject: Re: [Image-SIG] antialiasing in pil -2
It works for filled objects. With outlined objects the line of 1
pixel is too thin. Do you know how-to manipulate the outline
anyway thanks for your comment.
Kees van Drongelen.
im=im.resize((dxy*scale, dxy*scale), Image.NEAREST)
>"Anti-Aliasing" by definition is performed by rendering at a higher
>resolution and downsampling using interpolation. I'm not sure if PIL can
>automatically do this for you, but it's not hard to do yourself:
>-render at 2x, 3x, 4x, or higher resolution than you need
>-downsample the image using "bicubic" to the real size
>In other programs, you'll see the "Anti-aliasing" selection of "2x2, 3x3,
>4x4", etc, and that's bascially the "oversampling" you're setting above.
>Hope it helps...
grafische en interactieve vormgeving
2012 CT Haarlem
T 023 532 33 66
F 023 532 33 04