Thanks Jérôme, I will look into your code. Having other filter might be useful for my case.

While looking for code, I've also found this (pure python) implementation: http://stackoverflow.com/questions/12729228/simple-efficient-bilinear-interp...

Nicolas

On 14 Dec 2014, at 09:03, Jerome Kieffer Jerome.Kieffer@esrf.fr wrote:

On Sat, 13 Dec 2014 16:53:06 +0100 "Nicolas P. Rougier" Nicolas.Rougier@inria.fr wrote:

Hi all,

Does anyone has a simple 2D linear interpolation for resizing an image (without scipy) ?

Ideally, something like ```def zoom(Z, ratio): ...``` where Z is a 2D scalar array and ratio the scaling factor. (I'm currently using ```scipy.ndimage.interpolation.zoom``` but I would like to avoid the scipy dependency)

Hi Nicolas,

I have a self-contained cython class for that: https://github.com/kif/pyFAI/blob/master/src/bilinear.pyx

The formula for bilinear interpolation in implemented there but it needs some additionnal work for what you want to do.

Beside this I implemented an antialiased downscaler using Lanczos (order 1, 2 or 3) https://github.com/kif/imagizer/blob/qt/src/down_sampler.pyx.

Create a downscaler: ds = down_sampler.DownScaler() scaled_img = ds.scale(img, 4.5)

In this case the interpolation will be done on a vinicy of (2*4.5*3+1) pixel in the input image (and 2*3+1 in the output image) as it is doing Lanczos 3 by default. This implementation is 2x faster than the Antialiased downscaler in PIL.

Cheers,

-- Jérôme Kieffer Data analysis unit - ESRF _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion