[Image-SIG] downscaling by area averaging

Fredrik Lundh fredrik at pythonware.com
Fri May 6 13:29:58 CEST 2005

> what kind of source images are you processing?

this is what happens when you don't click on all links in a
message ;-)

some observations:

+ the sample you used sure illustrates why PIL's BILINEAR and
  BICUBIC fixed-size kernel filters are not very good for down-

+ in case anyone wants to play with PIL's internal stretch filters,
  you can use the following little wrapper function:

    def stretch(im, size, filter=Image.NEAREST):
        im = im._new(im.im.stretch(size, filter))
        return im

  supported filters are Image.NEAREST, BILINEAR, and BICUBIC,
  in addition to ANTIALIAS (which is already exposed via the
  "resize" method).  unlike their resize counterparts, the stretch
  filters use an adaptive kernel size (the more you downsample,
  the larger the kernel)

+ as expected, NEAREST stretch isn't too far from your results, but
  it's not identical (and it probably shouldn't be)

+ I'm beginning to wonder if there's not an off-by-something error
  lurking somewhere in stretch.  hmm...


More information about the Image-SIG mailing list