v3d.math.interp_img#

visu3d.math.interp_img(img: etils.enp.array_types.typing.Array, coords: etils.enp.array_types.typing.FloatArray, *, use_hw_coords: bool = False, xnp: Any = Ellipsis) etils.enp.array_types.typing.FloatArray[source]#

Bilinear interpolation of coordinates from an image.

The following assumptions are made:

  • Interpolation is performed from the pixel center (coords=[0.5, 0.5] match img[0, 0]).

  • Pixel coordinates are given in coords=[w, h], NOT [h, w]. This is consistent with cam.spec.px_centers() and OpenCv conventions. To invert, set use_hw_coords to True.

  • Coordinates outside the images use the image corners value.

Parameters:
  • img – Image from which interpolating values

  • coords – Pixel coordinates from which interpolate (in w, h convention, unless use_hw_coords is True, in which case it will use the h, w convention).

  • use_hw_coords – If True, coords will use (h, w convention).

  • xnp – Numpy module to use

Returns:

The interpolated pixel values at the requested coordinates. Note that returned value is always float (so interpolation of uint8 return float)