Function GetNearestNeighbor

Function Documentation

static int32_t GetNearestNeighbor(const int input_value, const int32_t input_size, const float scale, const float offset, const bool align_corners, const bool half_pixel_centers)

Map an output index to the nearest input index for resize.

This helper follows the TensorFlow Lite nearest-neighbor resize mapping rules.

Parameters:
  • input_value[in] Output index (x or y).

  • input_size[in] Input size along the same axis.

  • scale[in] Precomputed scaling factor for the axis.

  • offset[in] Precomputed offset for the axis.

  • align_corners[in] If true, use align-corners scaling.

  • half_pixel_centers[in] If true, use half-pixel center offset.

Returns:

Nearest input index for the given output index.