[Numpy-discussion] Bilinear interpolation (numpy only)
Jerome.Kieffer at esrf.fr
Sun Dec 14 03:03:47 EST 2014
On Sat, 13 Dec 2014 16:53:06 +0100
"Nicolas P. Rougier" <Nicolas.Rougier at 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)
I have a self-contained cython class for that:
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)
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.
Data analysis unit - ESRF
More information about the NumPy-Discussion