Shortcuts

mmcv.image.imrescale

mmcv.image.imrescale(img: numpy.ndarray, scale: Union[float, int, Tuple[int, int]], return_scale: bool = False, interpolation: str = 'bilinear', backend: Optional[str] = None)Union[numpy.ndarray, Tuple[numpy.ndarray, float]][source]

Resize image while keeping the aspect ratio.

Parameters
  • img (ndarray) – The input image.

  • scale (float | int | tuple[int]) – The scaling factor or maximum size. If it is a float number or an integer, then the image will be rescaled by this factor, else if it is a tuple of 2 integers, then the image will be rescaled as large as possible within the scale.

  • return_scale (bool) – Whether to return the scaling factor besides the rescaled image.

  • interpolation (str) – Same as resize().

  • backend (str | None) – Same as resize().

Returns

The rescaled image.

Return type

ndarray