Function get_index_from_xywh

Source
pub fn get_index_from_xywh(
    x: usize,
    y: usize,
    width: usize,
    height: usize,
    ndim: usize,
) -> Result<usize, Error>
Expand description

Compute 1D Index (row-major) when provided with the x, y coordinate, width and channel value.

§Arguments

  • x - The x coordinate (should be between 0 - width)
  • y - The y coordinate (should be between 0 - height)
  • width - The width of the x dimension
  • height - The height of the y dimension
  • ndim - The number of dimensions (ideally same as number of channels)

§Returns

  • usize containing Index if within bounds, otherwise Error