[Image-SIG] Re: aliasing on resize or thumnail?

Greg Abbas greg@cbcainc.com
Tue, 5 Feb 2002 15:04:30 -0800


This is a multi-part message in MIME format.

------=_NextPart_000_00A9_01C1AE56.69E9E040
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

I kinda have to agree with marc's line of reasoning on this. I've noticed
severe aliasing problems on transformed images too, and it seems like
there's no reason why bilinear or bicubic (or sinc or gaussian or ...)
resampling couldn't be implemented as described in the DSP textbooks, to
keep aliasing to a minimum regardless of whether the resulting image is
larger or smaller than the original. If you're doing any geometric transform
(scaling or rotation or something funkier), unless speed is the only
consideration don't you _always_ want to antialias?

Is anyone working on this?

-greg.

marc lindahl <marc@bowery.com> wrote:
> > They do blur the picture a little for me, in comparison if NEAREST. I
> > believe what is happening - by design - is that BILINEAR and BICUBIC are
> > just exactly that: they calculate each pixel color from the four pixels
> > closest to it in the original image.
>
> That's not how it's supposed to work, to be an antialising filter, is it?

it isn't an anti-aliasing filter: the BILINEAR and BICUBIC resampling
filters are intended for geometric transforms (rotations, quadrilateral
warps), not thumbnail generation.

(and the ANTIALIAS filter isn't available in 1.1.2)

you can get a better-than-nothing result by resizing multiple times
with the BILINEAR filter; untested:

    while im.size[0] > size[0] or im.size[1] > size[1]:
        im = im.resize(
            (max(size[0], im.size[0]/2), max(size[1], im.size[1]/2)),
            Image.BILINEAR
        )

</F>



------=_NextPart_000_00A9_01C1AE56.69E9E040
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4522.1800" name=3DGENERATOR></HEAD>
<BODY>
<DIV><SPAN class=3D502032922-05022002><FONT face=3DGaramond>I kinda have =
to agree=20
with marc's line of reasoning on this. I've noticed severe aliasing =
problems on=20
transformed images too, and it seems like there's no reason why bilinear =
or=20
bicubic (or sinc or gaussian or ...) resampling couldn't be implemented =
as=20
described in the DSP textbooks, to keep&nbsp;aliasing to a minimum =
regardless of=20
whether the resulting image is larger or smaller than the original. If =
you're=20
doing any geometric transform (scaling or rotation or something =
funkier), unless=20
speed is the only consideration don't you _always_ want to=20
antialias?</FONT></SPAN></DIV>
<DIV><SPAN class=3D502032922-05022002><FONT=20
face=3DGaramond></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D502032922-05022002><FONT face=3DGaramond>Is anyone =
working on=20
this?</FONT></SPAN></DIV>
<DIV><SPAN class=3D502032922-05022002><FONT=20
face=3DGaramond></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D502032922-05022002><FONT=20
face=3DGaramond>-greg.</FONT></SPAN></DIV>
<DIV><SPAN class=3D502032922-05022002><FONT=20
face=3DGaramond></FONT></SPAN>&nbsp;</DIV>
<DIV>marc lindahl &lt;<A =
href=3D"mailto:marc@bowery.com">marc@bowery.com</A>&gt;=20
wrote:<BR>&gt;<I> &gt; They do blur the picture a little for me, in =
comparison=20
if NEAREST. I<BR></I>&gt;<I> &gt; believe what is happening - by design =
- is=20
that BILINEAR and BICUBIC are<BR></I>&gt;<I> &gt; just exactly that: =
they=20
calculate each pixel color from the four pixels<BR></I>&gt;<I> &gt; =
closest to=20
it in the original image.<BR></I>&gt;<I><BR></I>&gt;<I> That's not how =
it's=20
supposed to work, to be an antialising filter, is it?<BR></I><BR>it =
isn't an=20
anti-aliasing filter: the BILINEAR and BICUBIC resampling<BR>filters are =

intended for geometric transforms (rotations, quadrilateral<BR>warps), =
not=20
thumbnail generation.<BR><BR>(and the ANTIALIAS filter isn't available =
in=20
1.1.2)<BR><BR>you can get a better-than-nothing result by resizing =
multiple=20
times<BR>with the BILINEAR filter; untested:<BR><BR>&nbsp;&nbsp;&nbsp; =
while=20
im.size[0] &gt; size[0] or im.size[1] &gt;=20
size[1]:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; im =3D=20
im.resize(<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;=20
(max(size[0], im.size[0]/2), max(size[1],=20
im.size[1]/2)),<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;=20
Image.BILINEAR<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
)<BR><BR>&lt;/F&gt;<BR></DIV>
<DIV><FONT face=3DGaramond></FONT>&nbsp;</DIV></BODY></HTML>

------=_NextPart_000_00A9_01C1AE56.69E9E040--