Discussion:
Lanczos interpolation
David Yan
2009-05-10 10:45:41 UTC
Permalink
I want to resize an image Lanczos interpolation but I haven't found any
python module that can do so. Also, I'm not knowledgeable enough to write
one myself. What's the best way I can do this? I use PIL currently but the
resampling filters don't suit my needs (antialias is too slow, bilinear and
bicubic produce aliasing when downsampling).
Fredrik Lundh
2009-05-12 12:35:41 UTC
Permalink
Post by David Yan
I want to resize an image Lanczos interpolation but I haven't found any
python module that can do so.  Also, I'm not knowledgeable enough to write
one myself.  What's the best way I can do this?  I use PIL currently but the
resampling filters don't suit my needs (antialias is too slow, bilinear and
bicubic produce aliasing when downsampling).
ANTIALIAS is a Lanczos interpolation written in C, so it's not
entirely obvious to me how you expect a Python version to be faster...

</F>
_______________________________________________
Image-SIG maillist - Image-***@python.org
http://mail.python.org/mailman/listinfo/image-sig
Franz Buchinger
2009-06-02 11:58:38 UTC
Permalink
A good old trick is to work with intermediate images: resize the image using
the Bilinear method and produce an intermediate image that is about 25%
larger than the final image.
Then you can downscale the intermediate image using Lanczos.

This should give a much better performance than working just with Lanczos,
especially for large downscaling ratios (e.g. 10 Megapixel JPEG -> 1024x768)
.
Image quality shouldn't be affected too much by this method.


Franz
Post by Fredrik Lundh
Post by David Yan
I want to resize an image Lanczos interpolation but I haven't found any
python module that can do so. Also, I'm not knowledgeable enough to
write
Post by David Yan
one myself. What's the best way I can do this? I use PIL currently but
the
Post by David Yan
resampling filters don't suit my needs (antialias is too slow, bilinear
and
Post by David Yan
bicubic produce aliasing when downsampling).
ANTIALIAS is a Lanczos interpolation written in C, so it's not
entirely obvious to me how you expect a Python version to be faster...
</F>
_______________________________________________
http://mail.python.org/mailman/listinfo/image-sig
Douglas Bagnall
2009-06-03 01:57:52 UTC
Permalink
If you want the downsampling algorithm used by the Gimp and (I think)
Photoshop, try:

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

In 2005 I found it to be a few times quicker than ANTIALIAS resizing,
and the results were better from what I was doing.

(From http://mail.python.org/pipermail/image-sig/2005-May/003310.html)


Douglas
_______________________________________________
Image-SIG maillist - Image-***@python.org
http://mail.python.org/mailman/listinfo/image-sig

Continue reading on narkive:
Loading...