Shortcuts

mmcv.image.imcrop

mmcv.image.imcrop(img: numpy.ndarray, bboxes: numpy.ndarray, scale: float = 1.0, pad_fill: Optional[Union[float, list]] = None)Union[numpy.ndarray, List[numpy.ndarray]][source]

Crop image patches.

3 steps: scale the bboxes -> clip bboxes -> crop and pad.

Parameters
  • img (ndarray) – Image to be cropped.

  • bboxes (ndarray) – Shape (k, 4) or (4, ), location of cropped bboxes.

  • scale (float, optional) – Scale ratio of bboxes, the default value 1.0 means no scaling.

  • pad_fill (Number | list[Number]) – Value to be filled for padding. Default: None, which means no padding.

Returns

The cropped image patches.

Return type

list[ndarray] | ndarray