mindspore/docs/api/api_python/dataset_vision/mindspore.dataset.vision.Ra...

29 lines
2.1 KiB
ReStructuredText
Raw Normal View History

mindspore.dataset.vision.RandomRotation
=======================================
2022-02-12 10:34:53 +08:00
.. py:class:: mindspore.dataset.vision.RandomRotation(degrees, resample=Inter.NEAREST, expand=False, center=None, fill_value=0)
2022-02-12 10:34:53 +08:00
在指定的角度范围内,随机旋转输入图像。
2022-07-11 18:56:38 +08:00
参数:
- **degrees** (Union[int, float, sequence]) - 旋转角度的随机选取范围。若输入单个数字,则从(-degrees, degrees)中随机生成旋转角度若输入2元素序列需按(min, max)顺序排列。
- **resample** (Inter, 可选) - 插值方式。它可以是 [Inter.BILINEAR, Inter.NEAREST, Inter.BICUBIC, Inter.AREA] 中的任何一个默认值Inter.NEAREST。
- Inter.BILINEAR双线性插值。
- Inter.NEAREST最近邻插值。
- Inter.BICUBIC双三次插值。
- Inter.AREA区域插值。
- **expand** (bool, 可选) - 若为True将扩展图像尺寸大小使其足以容纳整个旋转图像若为False则保持图像尺寸大小不变。请注意扩展时将假设图像为中心旋转且未进行平移。默认值False。
- **center** (tuple, 可选) - 可选的旋转中心,以图像左上角为原点,旋转中心的位置按照 (宽度, 高度) 格式指定。默认值None表示中心旋转。
- **fill_value** (Union[int, tuple[int]], 可选) - 旋转图像之外区域的像素填充值。若输入3元素元组将分别用于填充R、G、B通道若输入整型将以该值填充RGB通道。`fill_value` 值必须在 [0, 255] 范围内默认值0。
异常:
- **TypeError** - 当 `degrees` 的类型不为int、float或sequence。
- **TypeError** - 当 `resample` 的类型不为 :class:`mindspore.dataset.vision.Inter`
- **TypeError** - 当 `expand` 的类型不为bool。
- **TypeError** - 当 `center` 的类型不为tuple。
- **TypeError** - 当 `fill_value` 的类型不为int或tuple[int]。
- **ValueError** - 当 `fill_value` 取值不在[0, 255]范围内。
- **RuntimeError** - 当输入图像的shape不为<H, W>或<H, W, C>。