jax.image.resize

Contents

jax.image.resize#

jax.image.resize(image, shape, method, antialias=True, precision=Precision.HIGHEST)[source]#

Image resize.

The method argument expects one of the following resize methods:

ResizeMethod.NEAREST, "nearest"

Nearest neighbor interpolation. The values of antialias and precision are ignored.

ResizeMethod.LINEAR, "linear", "bilinear", "trilinear", "triangle"

Linear interpolation. If antialias is True, uses a triangular filter when downsampling.

ResizeMethod.CUBIC, "cubic", "bicubic", "tricubic"

Cubic interpolation, using the Keys cubic kernel.

ResizeMethod.LANCZOS3, "lanczos3"

Lanczos resampling, using a kernel of radius 3.

ResizeMethod.LANCZOS5, "lanczos5"

Lanczos resampling, using a kernel of radius 5.

Parameters:
  • image – a JAX array.

  • shape (core.Shape) – the output shape, as a sequence of integers with length equal to the number of dimensions of image. Note that resize() does not distinguish spatial dimensions from batch or channel dimensions, so this includes all dimensions of the image. To represent a batch or a channel dimension, simply leave that element of the shape unchanged.

  • method (str | ResizeMethod) – the resizing method to use; either a ResizeMethod instance or a string. Available methods are: LINEAR, LANCZOS3, LANCZOS5, CUBIC.

  • antialias (bool) – should an antialiasing filter be used when downsampling? Defaults to True. Has no effect when upsampling.

Returns:

The resized image.