@@ -8,7 +8,7 @@ mindarmour.natural_robustness.transform.image | |||||
图像的对比度。 | 图像的对比度。 | ||||
参数: | 参数: | ||||
- **alpha** (Union[float, int]) - 控制图像的对比度。:math:`out\_image = in\_image*alpha+beta`。建议值范围[0.2, 2]。 | |||||
- **alpha** (Union[float, int]) - 控制图像的对比度。:math:`out\_image = in\_image \times alpha+beta`。建议值范围[0.2, 2]。默认值:1。 | |||||
- **beta** (Union[float, int]) - 补充alpha的增量。默认值:0。 | - **beta** (Union[float, int]) - 补充alpha的增量。默认值:0。 | ||||
- **auto_param** (bool) - 自动选择参数。在保留图像的语义的范围内自动选择参数。默认值:False。 | - **auto_param** (bool) - 自动选择参数。在保留图像的语义的范围内自动选择参数。默认值:False。 | ||||
@@ -17,13 +17,13 @@ mindarmour.natural_robustness.transform.image | |||||
渐变调整图片的亮度。 | 渐变调整图片的亮度。 | ||||
参数: | 参数: | ||||
- **color_start** (union[tuple, list]) - 渐变中心的颜色。默认值:(0,0,0)。 | |||||
- **color_end** (union[tuple, list]) - 渐变边缘的颜色。默认值:(255,255,255)。 | |||||
- **start_point** (union[tuple, list]) - 渐变中心的二维坐标。 | |||||
- **scope** (float) - 渐变的范围。值越大,渐变范围越大。默认值:0.3。 | |||||
- **pattern** (str) - 深色或浅色,此值必须在['light', 'dark']中。 | |||||
- **bright_rate** (float) - 控制亮度。值越大,梯度范围越大。如果参数 `pattern` 为'light',建议值范围为[0.1, 0.7],如果参数 `pattern` 为'dark',建议值范围为[0.1, 0.9]。 | |||||
- **mode** (str) - 渐变模式,值必须在['circle', 'horizontal', 'vertical']中。 | |||||
- **color_start** (union[tuple, list]) - 渐变中心的颜色。默认值:(0, 0, 0)。 | |||||
- **color_end** (union[tuple, list]) - 渐变边缘的颜色。默认值:(255, 255, 255)。 | |||||
- **start_point** (union[tuple, list]) - 渐变中心的二维坐标。默认值:(10, 10) | |||||
- **scope** (float) - 渐变的范围。值越大,渐变范围越大。默认值:0.5。 | |||||
- **pattern** (str) - 深色或浅色,此值必须在['light', 'dark']中。默认值:'light'。 | |||||
- **bright_rate** (float) - 控制亮度。值越大,梯度范围越大。如果参数 `pattern` 为'light',建议值范围为[0.1, 0.7],如果参数 `pattern` 为'dark',建议值范围为[0.1, 0.9]。默认值:0.3。 | |||||
- **mode** (str) - 渐变模式,值必须在['circle', 'horizontal', 'vertical']中。默认值:'circle'。 | |||||
- **auto_param** (bool) - 自动选择参数。在保留图像的语义的范围内自动选择参数。默认值:False。 | - **auto_param** (bool) - 自动选择参数。在保留图像的语义的范围内自动选择参数。默认值:False。 | ||||
.. py:class:: mindarmour.natural_robustness.transform.image.GaussianBlur(ksize=2, auto_param=False) | .. py:class:: mindarmour.natural_robustness.transform.image.GaussianBlur(ksize=2, auto_param=False) | ||||
@@ -31,7 +31,7 @@ mindarmour.natural_robustness.transform.image | |||||
使用高斯模糊滤镜模糊图像。 | 使用高斯模糊滤镜模糊图像。 | ||||
参数: | 参数: | ||||
- **ksize** (int) - 高斯核的大小,必须为非负数。 | |||||
- **ksize** (int) - 高斯核的大小,必须为非负数。默认值:2。 | |||||
- **auto_param** (bool) - 自动选择参数。在保留图像的语义的范围内自动选择参数。默认值:False。 | - **auto_param** (bool) - 自动选择参数。在保留图像的语义的范围内自动选择参数。默认值:False。 | ||||
.. py:class:: mindarmour.natural_robustness.transform.image.MotionBlur(degree=5, angle=45, auto_param=False) | .. py:class:: mindarmour.natural_robustness.transform.image.MotionBlur(degree=5, angle=45, auto_param=False) | ||||
@@ -39,8 +39,8 @@ mindarmour.natural_robustness.transform.image | |||||
运动模糊。 | 运动模糊。 | ||||
参数: | 参数: | ||||
- **degree** (int) - 模糊程度。必须为正值。建议取值范围[1, 15]。 | |||||
- **angle** (union[float, int]) - 运动模糊的方向。angle=0表示上下运动模糊。角度为逆时针方向。 | |||||
- **degree** (int) - 模糊程度。必须为正值。建议取值范围[1, 15]。默认值:5。 | |||||
- **angle** (union[float, int]) - 运动模糊的方向。angle=0表示上下运动模糊。角度为逆时针方向。默认值:45。 | |||||
- **auto_param** (bool) - 自动选择参数。在保留图像的语义的范围内自动选择参数。默认值:False。 | - **auto_param** (bool) - 自动选择参数。在保留图像的语义的范围内自动选择参数。默认值:False。 | ||||
@@ -50,7 +50,7 @@ mindarmour.natural_robustness.transform.image | |||||
参数: | 参数: | ||||
- **point** (union[tuple, list]) - 模糊中心点的二维坐标。 | - **point** (union[tuple, list]) - 模糊中心点的二维坐标。 | ||||
- **kernel_num** (int) - 模糊核的数量。建议取值范围[1, 8]。 | |||||
- **kernel_num** (int) - 模糊核的数量。建议取值范围[1, 8]。默认值:3。 | |||||
- **center** (bool) - 指定中心点模糊或指定中心点清晰。默认值:True。 | - **center** (bool) - 指定中心点模糊或指定中心点清晰。默认值:True。 | ||||
- **auto_param** (bool) - 自动选择参数。在保留图像的语义的范围内自动选择参数。默认值:False。 | - **auto_param** (bool) - 自动选择参数。在保留图像的语义的范围内自动选择参数。默认值:False。 | ||||
@@ -59,7 +59,7 @@ mindarmour.natural_robustness.transform.image | |||||
图像添加均匀噪声。 | 图像添加均匀噪声。 | ||||
参数: | 参数: | ||||
- **factor** (float) - 噪声密度,单位像素区域添加噪声的比例。建议取值范围:[0.001, 0.15]。 | |||||
- **factor** (float) - 噪声密度,单位像素区域添加噪声的比例。建议取值范围:[0.001, 0.15]。默认值:0.1。 | |||||
- **auto_param** (bool) - 自动选择参数。在保留图像的语义的范围内自动选择参数。默认值:False。 | - **auto_param** (bool) - 自动选择参数。在保留图像的语义的范围内自动选择参数。默认值:False。 | ||||
.. py:class:: mindarmour.natural_robustness.transform.image.GaussianNoise(factor=0.1, auto_param=False) | .. py:class:: mindarmour.natural_robustness.transform.image.GaussianNoise(factor=0.1, auto_param=False) | ||||
@@ -67,7 +67,7 @@ mindarmour.natural_robustness.transform.image | |||||
图像添加高斯噪声。 | 图像添加高斯噪声。 | ||||
参数: | 参数: | ||||
- **factor** (float) - 噪声密度,单位像素区域添加噪声的比例。建议取值范围:[0.001, 0.15]。 | |||||
- **factor** (float) - 噪声密度,单位像素区域添加噪声的比例。建议取值范围:[0.001, 0.15]。默认值:0.1。 | |||||
- **auto_param** (bool) - 自动选择参数。在保留图像的语义的范围内自动选择参数。默认值:False。 | - **auto_param** (bool) - 自动选择参数。在保留图像的语义的范围内自动选择参数。默认值:False。 | ||||
.. py:class:: mindarmour.natural_robustness.transform.image.SaltAndPepperNoise(factor=0, auto_param=False) | .. py:class:: mindarmour.natural_robustness.transform.image.SaltAndPepperNoise(factor=0, auto_param=False) | ||||
@@ -75,7 +75,7 @@ mindarmour.natural_robustness.transform.image | |||||
图像添加椒盐噪声。 | 图像添加椒盐噪声。 | ||||
参数: | 参数: | ||||
- **factor** (float) - 噪声密度,单位像素区域添加噪声的比例。建议取值范围:[0.001, 0.15]。 | |||||
- **factor** (float) - 噪声密度,单位像素区域添加噪声的比例。建议取值范围:[0.001, 0.15]。默认值:0。 | |||||
- **auto_param** (bool) - 自动选择参数。在保留图像的语义的范围内自动选择参数。默认值:False。 | - **auto_param** (bool) - 自动选择参数。在保留图像的语义的范围内自动选择参数。默认值:False。 | ||||
.. py:class:: mindarmour.natural_robustness.transform.image.NaturalNoise(ratio=0.0002, k_x_range=(1, 5), k_y_range=(3, 25), auto_param=False) | .. py:class:: mindarmour.natural_robustness.transform.image.NaturalNoise(ratio=0.0002, k_x_range=(1, 5), k_y_range=(3, 25), auto_param=False) | ||||
@@ -83,9 +83,9 @@ mindarmour.natural_robustness.transform.image | |||||
图像添加自然噪声。 | 图像添加自然噪声。 | ||||
参数: | 参数: | ||||
- **ratio** (float) - 噪声密度,单位像素区域添加噪声的比例。建议取值范围:[0.00001, 0.001]。 | |||||
- **k_x_range** (union[list, tuple]) - 噪声块长度的取值范围。 | |||||
- **k_y_range** (union[list, tuple]) - 噪声块宽度的取值范围。 | |||||
- **ratio** (float) - 噪声密度,单位像素区域添加噪声的比例。建议取值范围:[0.00001, 0.001]。默认值:0.0002。 | |||||
- **k_x_range** (union[list, tuple]) - 噪声块长度的取值范围。默认值:(1, 5)。 | |||||
- **k_y_range** (union[list, tuple]) - 噪声块宽度的取值范围。默认值:(3, 25)。 | |||||
- **auto_param** (bool) - 自动选择参数。在保留图像的语义的范围内自动选择参数。默认值:False。 | - **auto_param** (bool) - 自动选择参数。在保留图像的语义的范围内自动选择参数。默认值:False。 | ||||
.. py:class:: mindarmour.natural_robustness.transform.image.Translate(x_bias=0, y_bias=0, auto_param=False) | .. py:class:: mindarmour.natural_robustness.transform.image.Translate(x_bias=0, y_bias=0, auto_param=False) | ||||
@@ -93,8 +93,8 @@ mindarmour.natural_robustness.transform.image | |||||
图像平移。 | 图像平移。 | ||||
参数: | 参数: | ||||
- **x_bias** (Union[int, float]) - X方向平移,x = x + x_bias*图像长度。建议取值范围在[-0.1, 0.1]中。 | |||||
- **y_bias** (Union[int, float]) - Y方向平移,y = y + y_bias*图像长度。建议取值范围在[-0.1, 0.1]中。 | |||||
- **x_bias** (Union[int, float]) - X方向平移, :math:`x = x + x_bias \times image\_length` 。建议取值范围在[-0.1, 0.1]中。默认值:0。 | |||||
- **y_bias** (Union[int, float]) - Y方向平移, :math:`y = y + y_bias \times image\_width` 。建议取值范围在[-0.1, 0.1]中。默认值:0。 | |||||
- **auto_param** (bool) - 自动选择参数。在保留图像的语义的范围内自动选择参数。默认值:False。 | - **auto_param** (bool) - 自动选择参数。在保留图像的语义的范围内自动选择参数。默认值:False。 | ||||
.. py:class:: mindarmour.natural_robustness.transform.image.Scale(factor_x=1, factor_y=1, auto_param=False) | .. py:class:: mindarmour.natural_robustness.transform.image.Scale(factor_x=1, factor_y=1, auto_param=False) | ||||
@@ -102,17 +102,17 @@ mindarmour.natural_robustness.transform.image | |||||
图像缩放。 | 图像缩放。 | ||||
参数: | 参数: | ||||
- **factor_x** (Union[float, int]) - 在X方向缩放,x=factor_x*x。建议取值范围在[0.5, 1]且abs(factor_y - factor_x) < 0.5。 | |||||
- **factor_y** (Union[float, int]) - 沿Y方向缩放,y=factor_y*y。建议取值范围在[0.5, 1]且abs(factor_y - factor_x) < 0.5。 | |||||
- **factor_x** (Union[float, int]) - 在X方向缩放, :math:`x=factor_x \times x` 。建议取值范围在[0.5, 1]且abs(factor_y - factor_x) < 0.5。默认值:1。 | |||||
- **factor_y** (Union[float, int]) - 沿Y方向缩放, :math:`y=factor_y \times y` 。建议取值范围在[0.5, 1]且abs(factor_y - factor_x) < 0.5。默认值:1。 | |||||
- **auto_param** (bool) - 自动选择参数。在保留图像的语义的范围内自动选择参数。默认值:False。 | - **auto_param** (bool) - 自动选择参数。在保留图像的语义的范围内自动选择参数。默认值:False。 | ||||
.. py:class:: mindarmour.natural_robustness.transform.image.Shear(factor=0.2, direction='horizontal', auto_param=False) | .. py:class:: mindarmour.natural_robustness.transform.image.Shear(factor=0.2, direction='horizontal', auto_param=False) | ||||
图像错切,错切后图像和原图的映射关系为:(new_x, new_y) = (x+factor_x*y, factor_y*x+y)。错切后图像将重新缩放到原图大小。 | |||||
图像错切,错切后图像和原图的映射关系为: :math:`(new_x, new_y) = (x+factor_x \times y, factor_y \times x+y)` 。错切后图像将重新缩放到原图大小。 | |||||
参数: | 参数: | ||||
- **factor** (Union[float, int]) - 沿错切方向上的错切比例。建议值范围[0.05, 0.5]。 | |||||
- **direction** (str) - 形变方向。可选值为'vertical'或'horizontal'。 | |||||
- **factor** (Union[float, int]) - 沿错切方向上的错切比例。建议值范围[0.05, 0.5]。默认值:0.2。 | |||||
- **direction** (str) - 形变方向。可选值为'vertical'或'horizontal'。默认值:'horizontal'。 | |||||
- **auto_param** (bool) - 自动选择参数。在保留图像的语义的范围内自动选择参数。默认值:False。 | - **auto_param** (bool) - 自动选择参数。在保留图像的语义的范围内自动选择参数。默认值:False。 | ||||
.. py:class:: mindarmour.natural_robustness.transform.image.Rotate(angle=20, auto_param=False) | .. py:class:: mindarmour.natural_robustness.transform.image.Rotate(angle=20, auto_param=False) | ||||
@@ -120,7 +120,7 @@ mindarmour.natural_robustness.transform.image | |||||
围绕图像中心点逆时针旋转图像。 | 围绕图像中心点逆时针旋转图像。 | ||||
参数: | 参数: | ||||
- **angle** (Union[float, int]) - 逆时针旋转的度数。建议值范围[-60, 60]。 | |||||
- **angle** (Union[float, int]) - 逆时针旋转的度数。建议值范围[-60, 60]。默认值:20。 | |||||
- **auto_param** (bool) - 自动选择参数。在保留图像的语义的范围内自动选择参数。默认值:False。 | - **auto_param** (bool) - 自动选择参数。在保留图像的语义的范围内自动选择参数。默认值:False。 | ||||
.. py:class:: mindarmour.natural_robustness.transform.image.Perspective(ori_pos, dst_pos, auto_param=False) | .. py:class:: mindarmour.natural_robustness.transform.image.Perspective(ori_pos, dst_pos, auto_param=False) | ||||
@@ -128,8 +128,8 @@ mindarmour.natural_robustness.transform.image | |||||
透视变换。 | 透视变换。 | ||||
参数: | 参数: | ||||
- **ori_pos** (list) - 原始图像中的四个点的坐标。 | |||||
- **dst_pos** (list) - 对应的ori_pos中4个点透视变换后的点坐标。 | |||||
- **ori_pos** (list[list[int]]) - 原始图像中的四个点的坐标。 | |||||
- **dst_pos** (list[list[int]]) - 对应的 `ori_pos` 中4个点透视变换后的点坐标。 | |||||
- **auto_param** (bool) - 自动选择参数。在保留图像的语义的范围内自动选择参数。默认值:False。 | - **auto_param** (bool) - 自动选择参数。在保留图像的语义的范围内自动选择参数。默认值:False。 | ||||
.. py:class:: mindarmour.natural_robustness.transform.image.Curve(curves=3, depth=10, mode='vertical', auto_param=False) | .. py:class:: mindarmour.natural_robustness.transform.image.Curve(curves=3, depth=10, mode='vertical', auto_param=False) | ||||
@@ -137,7 +137,7 @@ mindarmour.natural_robustness.transform.image | |||||
使用Sin函数的曲线变换。 | 使用Sin函数的曲线变换。 | ||||
参数: | 参数: | ||||
- **curves** (union[float, int]) - 曲线周期数。建议取值范围[0.1, 5]。 | |||||
- **depth** (union[float, int]) - sin函数的幅度。建议取值不超过图片长度的1/10。 | |||||
- **mode** (str) - 形变方向。可选值'vertical'或'horizontal'。 | |||||
- **curves** (union[float, int]) - 曲线周期数。建议取值范围[0.1, 5]。默认值:3。 | |||||
- **depth** (union[float, int]) - sin函数的幅度。建议取值不超过图片长度的1/10。默认值:10。 | |||||
- **mode** (str) - 形变方向。可选值'vertical'或'horizontal'。默认值:'vertical'。 | |||||
- **auto_param** (bool) - 自动选择参数。在保留图像的语义的范围内自动选择参数。默认值:False。 | - **auto_param** (bool) - 自动选择参数。在保留图像的语义的范围内自动选择参数。默认值:False。 |
@@ -31,11 +31,12 @@ class GaussianBlur(_NaturalPerturb): | |||||
Blurs the image using Gaussian blur filter. | Blurs the image using Gaussian blur filter. | ||||
Args: | Args: | ||||
ksize (int): Size of gaussian kernel, this value must be non-negnative. | |||||
ksize (int): Size of gaussian kernel, this value must be non-negnative. Default: 2. | |||||
auto_param (bool): Auto selected parameters. Selected parameters will preserve semantics of image. | auto_param (bool): Auto selected parameters. Selected parameters will preserve semantics of image. | ||||
Default: False. | Default: False. | ||||
Examples: | Examples: | ||||
>>> import cv2 | |||||
>>> img = cv2.imread('1.png') | >>> img = cv2.imread('1.png') | ||||
>>> img = np.array(img) | >>> img = np.array(img) | ||||
>>> ksize = 5 | >>> ksize = 5 | ||||
@@ -74,13 +75,14 @@ class MotionBlur(_NaturalPerturb): | |||||
Motion blur for a given image. | Motion blur for a given image. | ||||
Args: | Args: | ||||
degree (int): Degree of blur. This value must be positive. Suggested value range in [1, 15]. | |||||
degree (int): Degree of blur. This value must be positive. Suggested value range in [1, 15]. Default: 5. | |||||
angle (union[float, int]): Direction of motion blur. Angle=0 means up and down motion blur. Angle is | angle (union[float, int]): Direction of motion blur. Angle=0 means up and down motion blur. Angle is | ||||
counterclockwise. | |||||
counterclockwise. Default: 45. | |||||
auto_param (bool): Auto selected parameters. Selected parameters will preserve semantics of image. | auto_param (bool): Auto selected parameters. Selected parameters will preserve semantics of image. | ||||
Default: False. | Default: False. | ||||
Examples: | Examples: | ||||
>>> import cv2 | |||||
>>> img = cv2.imread('1.png') | >>> img = cv2.imread('1.png') | ||||
>>> img = np.array(img) | >>> img = np.array(img) | ||||
>>> angle = 0 | >>> angle = 0 | ||||
@@ -130,12 +132,13 @@ class GradientBlur(_NaturalPerturb): | |||||
Args: | Args: | ||||
point (union[tuple, list]): 2D coordinate of the Blur center point. | point (union[tuple, list]): 2D coordinate of the Blur center point. | ||||
kernel_num (int): Number of blur kernels. Suggested value range in [1, 8]. | |||||
kernel_num (int): Number of blur kernels. Suggested value range in [1, 8]. Default: 3. | |||||
center (bool): Blurred or clear at the center of a specified point. | center (bool): Blurred or clear at the center of a specified point. | ||||
auto_param (bool): Auto selected parameters. Selected parameters will preserve semantics of image. | auto_param (bool): Auto selected parameters. Selected parameters will preserve semantics of image. | ||||
Default: False. | Default: False. | ||||
Examples: | Examples: | ||||
>>> import cv2 | |||||
>>> img = cv2.imread('xx.png') | >>> img = cv2.imread('xx.png') | ||||
>>> img = np.array(img) | >>> img = np.array(img) | ||||
>>> number = 5 | >>> number = 5 | ||||
@@ -32,11 +32,12 @@ class UniformNoise(_NaturalPerturb): | |||||
Args: | Args: | ||||
factor (float): Noise density, the proportion of noise points per unit pixel area. Suggested value range in | factor (float): Noise density, the proportion of noise points per unit pixel area. Suggested value range in | ||||
[0.001, 0.15]. | |||||
[0.001, 0.15]. Default: 0.1. | |||||
auto_param (bool): Auto selected parameters. Selected parameters will preserve semantics of image. | auto_param (bool): Auto selected parameters. Selected parameters will preserve semantics of image. | ||||
Default: False. | Default: False. | ||||
Examples: | Examples: | ||||
>>> import cv2 | |||||
>>> img = cv2.imread('1.png') | >>> img = cv2.imread('1.png') | ||||
>>> img = np.array(img) | >>> img = np.array(img) | ||||
>>> factor = 0.1 | >>> factor = 0.1 | ||||
@@ -78,11 +79,12 @@ class GaussianNoise(_NaturalPerturb): | |||||
Args: | Args: | ||||
factor (float): Noise density, the proportion of noise points per unit pixel area. Suggested value range in | factor (float): Noise density, the proportion of noise points per unit pixel area. Suggested value range in | ||||
[0.001, 0.15]. | |||||
[0.001, 0.15]. Default: 0.1. | |||||
auto_param (bool): Auto selected parameters. Selected parameters will preserve semantics of image. | auto_param (bool): Auto selected parameters. Selected parameters will preserve semantics of image. | ||||
Default: False. | Default: False. | ||||
Examples: | Examples: | ||||
>>> import cv2 | |||||
>>> img = cv2.imread('1.png') | >>> img = cv2.imread('1.png') | ||||
>>> img = np.array(img) | >>> img = np.array(img) | ||||
>>> factor = 0.1 | >>> factor = 0.1 | ||||
@@ -123,11 +125,12 @@ class SaltAndPepperNoise(_NaturalPerturb): | |||||
Args: | Args: | ||||
factor (float): Noise density, the proportion of noise points per unit pixel area. Suggested value range in | factor (float): Noise density, the proportion of noise points per unit pixel area. Suggested value range in | ||||
[0.001, 0.15]. | |||||
[0.001, 0.15]. Default: 0. | |||||
auto_param (bool): Auto selected parameters. Selected parameters will preserve semantics of image. | auto_param (bool): Auto selected parameters. Selected parameters will preserve semantics of image. | ||||
Default: False. | Default: False. | ||||
Examples: | Examples: | ||||
>>> import cv2 | |||||
>>> img = cv2.imread('1.png') | >>> img = cv2.imread('1.png') | ||||
>>> img = np.array(img) | >>> img = np.array(img) | ||||
>>> factor = 0.1 | >>> factor = 0.1 | ||||
@@ -171,12 +174,13 @@ class NaturalNoise(_NaturalPerturb): | |||||
Args: | Args: | ||||
ratio (float): Noise density, the proportion of noise blocks per unit pixel area. Suggested value range in | ratio (float): Noise density, the proportion of noise blocks per unit pixel area. Suggested value range in | ||||
[0.00001, 0.001]. | [0.00001, 0.001]. | ||||
k_x_range (union[list, tuple]): Value range of the noise block length. | |||||
k_y_range (union[list, tuple]): Value range of the noise block width. | |||||
k_x_range (union[list, tuple]): Value range of the noise block length. Default: (1, 5). | |||||
k_y_range (union[list, tuple]): Value range of the noise block width. Default: (3, 25). | |||||
auto_param (bool): Auto selected parameters. Selected parameters will preserve semantics of image. | auto_param (bool): Auto selected parameters. Selected parameters will preserve semantics of image. | ||||
Default: False. | Default: False. | ||||
Examples: | Examples: | ||||
>>> import cv2 | |||||
>>> img = cv2.imread('xx.png') | >>> img = cv2.imread('xx.png') | ||||
>>> img = np.array(img) | >>> img = np.array(img) | ||||
>>> ratio = 0.0002 | >>> ratio = 0.0002 | ||||
@@ -32,13 +32,14 @@ class Contrast(_NaturalPerturb): | |||||
Contrast of an image. | Contrast of an image. | ||||
Args: | Args: | ||||
alpha (Union[float, int]): Control the contrast of an image. :math:`out\_image = in\_image*alpha+beta`. | |||||
Suggested value range in [0.2, 2]. | |||||
alpha (Union[float, int]): Control the contrast of an image. :math:`out\_image = in\_image \times alpha+beta`. | |||||
Suggested value range in [0.2, 2]. Default: 1. | |||||
beta (Union[float, int]): Delta added to alpha. Default: 0. | beta (Union[float, int]): Delta added to alpha. Default: 0. | ||||
auto_param (bool): Auto selected parameters. Selected parameters will preserve semantics of image. | auto_param (bool): Auto selected parameters. Selected parameters will preserve semantics of image. | ||||
Default: False. | Default: False. | ||||
Examples: | Examples: | ||||
>>> import cv2 | |||||
>>> img = cv2.imread('1.png') | >>> img = cv2.imread('1.png') | ||||
>>> img = np.array(img) | >>> img = np.array(img) | ||||
>>> alpha = 0.1 | >>> alpha = 0.1 | ||||
@@ -206,16 +207,17 @@ class GradientLuminance(_NaturalPerturb): | |||||
color_start (union[tuple, list]): Color of gradient center. Default:(0, 0, 0). | color_start (union[tuple, list]): Color of gradient center. Default:(0, 0, 0). | ||||
color_end (union[tuple, list]): Color of gradient edge. Default:(255, 255, 255). | color_end (union[tuple, list]): Color of gradient edge. Default:(255, 255, 255). | ||||
start_point (union[tuple, list]): 2D coordinate of gradient center. | start_point (union[tuple, list]): 2D coordinate of gradient center. | ||||
scope (float): Range of the gradient. A larger value indicates a larger gradient range. Default: 0.3. | |||||
pattern (str): Dark or light, this value must be in ['light', 'dark']. | |||||
scope (float): Range of the gradient. A larger value indicates a larger gradient range. Default: 0.5. | |||||
pattern (str): Dark or light, this value must be in ['light', 'dark']. Default: 'light'. | |||||
bright_rate (float): Control brightness. A larger value indicates a larger gradient range. If parameter | bright_rate (float): Control brightness. A larger value indicates a larger gradient range. If parameter | ||||
'pattern' is 'light', Suggested value range in [0.1, 0.7], if parameter 'pattern' is 'dark', Suggested value | 'pattern' is 'light', Suggested value range in [0.1, 0.7], if parameter 'pattern' is 'dark', Suggested value | ||||
range in [0.1, 0.9]. | |||||
mode (str): Gradient mode, value must be in ['circle', 'horizontal', 'vertical']. | |||||
range in [0.1, 0.9]. Default: 0.3. | |||||
mode (str): Gradient mode, value must be in ['circle', 'horizontal', 'vertical']. Default: 'circle'. | |||||
auto_param (bool): Auto selected parameters. Selected parameters will preserve semantics of image. | auto_param (bool): Auto selected parameters. Selected parameters will preserve semantics of image. | ||||
Default: False. | Default: False. | ||||
Examples: | Examples: | ||||
>>> import cv2 | |||||
>>> img = cv2.imread('x.png') | >>> img = cv2.imread('x.png') | ||||
>>> height, width = img.shape[:2] | >>> height, width = img.shape[:2] | ||||
>>> point = (height // 4, width // 2) | >>> point = (height // 4, width // 2) | ||||
@@ -32,13 +32,14 @@ class Translate(_NaturalPerturb): | |||||
Args: | Args: | ||||
x_bias (Union[int, float]): X-direction translation, x = x + x_bias*image_width. Suggested value range | x_bias (Union[int, float]): X-direction translation, x = x + x_bias*image_width. Suggested value range | ||||
in [-0.1, 0.1]. | |||||
in [-0.1, 0.1]. Default: 0. | |||||
y_bias (Union[int, float]): Y-direction translation, y = y + y_bias*image_length. Suggested value range | y_bias (Union[int, float]): Y-direction translation, y = y + y_bias*image_length. Suggested value range | ||||
in [-0.1, 0.1]. | |||||
in [-0.1, 0.1]. Default: 0. | |||||
auto_param (bool): Auto selected parameters. Selected parameters will preserve semantics of image. | auto_param (bool): Auto selected parameters. Selected parameters will preserve semantics of image. | ||||
Default: False. | Default: False. | ||||
Examples: | Examples: | ||||
>>> import cv2 | |||||
>>> img = cv2.imread('1.png') | >>> img = cv2.imread('1.png') | ||||
>>> img = np.array(img) | >>> img = np.array(img) | ||||
>>> x_bias = 0.1 | >>> x_bias = 0.1 | ||||
@@ -80,13 +81,14 @@ class Scale(_NaturalPerturb): | |||||
Args: | Args: | ||||
factor_x (Union[float, int]): Rescale in X-direction, x=factor_x*x. Suggested value range in [0.5, 1] and | factor_x (Union[float, int]): Rescale in X-direction, x=factor_x*x. Suggested value range in [0.5, 1] and | ||||
abs(factor_y - factor_x) < 0.5. | |||||
abs(factor_y - factor_x) < 0.5. Default: 1. | |||||
factor_y (Union[float, int]): Rescale in Y-direction, y=factor_y*y. Suggested value range in [0.5, 1] and | factor_y (Union[float, int]): Rescale in Y-direction, y=factor_y*y. Suggested value range in [0.5, 1] and | ||||
abs(factor_y - factor_x) < 0.5. | |||||
abs(factor_y - factor_x) < 0.5. Default: 1. | |||||
auto_param (bool): Auto selected parameters. Selected parameters will preserve semantics of image. | auto_param (bool): Auto selected parameters. Selected parameters will preserve semantics of image. | ||||
Default: False. | Default: False. | ||||
Examples: | Examples: | ||||
>>> import cv2 | |||||
>>> img = cv2.imread('1.png') | >>> img = cv2.imread('1.png') | ||||
>>> img = np.array(img) | >>> img = np.array(img) | ||||
>>> factor_x = 0.7 | >>> factor_x = 0.7 | ||||
@@ -129,12 +131,13 @@ class Shear(_NaturalPerturb): | |||||
Then the sheared image will be rescaled to fit original size. | Then the sheared image will be rescaled to fit original size. | ||||
Args: | Args: | ||||
factor (Union[float, int]): Shear rate in shear direction. Suggested value range in [0.05, 0.5]. | |||||
direction (str): Direction of deformation. Optional value is 'vertical' or 'horizontal'. | |||||
factor (Union[float, int]): Shear rate in shear direction. Suggested value range in [0.05, 0.5]. Default: 0.2. | |||||
direction (str): Direction of deformation. Optional value is 'vertical' or 'horizontal'. Default: 'horizontal'. | |||||
auto_param (bool): Auto selected parameters. Selected parameters will preserve semantics of image. | auto_param (bool): Auto selected parameters. Selected parameters will preserve semantics of image. | ||||
Default: False. | Default: False. | ||||
Examples: | Examples: | ||||
>>> import cv2 | |||||
>>> img = cv2.imread('1.png') | >>> img = cv2.imread('1.png') | ||||
>>> img = np.array(img) | >>> img = np.array(img) | ||||
>>> factor = 0.2 | >>> factor = 0.2 | ||||
@@ -186,11 +189,12 @@ class Rotate(_NaturalPerturb): | |||||
Rotate an image of counter clockwise around its center. | Rotate an image of counter clockwise around its center. | ||||
Args: | Args: | ||||
angle (Union[float, int]): Degrees of counter clockwise. Suggested value range in [-60, 60]. | |||||
angle (Union[float, int]): Degrees of counter clockwise. Suggested value range in [-60, 60]. Default: 20. | |||||
auto_param (bool): Auto selected parameters. Selected parameters will preserve semantics of image. | auto_param (bool): Auto selected parameters. Selected parameters will preserve semantics of image. | ||||
Default: False. | Default: False. | ||||
Examples: | Examples: | ||||
>>> import cv2 | |||||
>>> img = cv2.imread('1.png') | >>> img = cv2.imread('1.png') | ||||
>>> img = np.array(img) | >>> img = np.array(img) | ||||
>>> angle = 20 | >>> angle = 20 | ||||
@@ -240,12 +244,13 @@ class Perspective(_NaturalPerturb): | |||||
Perform perspective transformation on a given picture. | Perform perspective transformation on a given picture. | ||||
Args: | Args: | ||||
ori_pos (list): Four points in original image. | |||||
dst_pos (list): The point coordinates of the 4 points in ori_pos after perspective transformation. | |||||
ori_pos (list[list[int]]): Four points in original image. | |||||
dst_pos (list[list[int]]): The point coordinates of the 4 points in `ori_pos` after perspective transformation. | |||||
auto_param (bool): Auto selected parameters. Selected parameters will preserve semantics of image. | auto_param (bool): Auto selected parameters. Selected parameters will preserve semantics of image. | ||||
Default: False. | Default: False. | ||||
Examples: | Examples: | ||||
>>> import cv2 | |||||
>>> img = cv2.imread('1.png') | >>> img = cv2.imread('1.png') | ||||
>>> img = np.array(img) | >>> img = np.array(img) | ||||
>>> ori_pos = [[0, 0], [0, 800], [800, 0], [800, 800]] | >>> ori_pos = [[0, 0], [0, 800], [800, 0], [800, 800]] | ||||
@@ -297,14 +302,15 @@ class Curve(_NaturalPerturb): | |||||
Curve picture using sin method. | Curve picture using sin method. | ||||
Args: | Args: | ||||
curves (union[float, int]): Number of curve cycles. Suggested value range in [0.1, 5]. | |||||
curves (union[float, int]): Number of curve cycles. Suggested value range in [0.1, 5]. Default: 3. | |||||
depth (union[float, int]): Amplitude of sin method. Suggested value not exceed 1/10 of the length of the | depth (union[float, int]): Amplitude of sin method. Suggested value not exceed 1/10 of the length of the | ||||
picture. | |||||
mode (str): Direction of deformation. Optional value is 'vertical' or 'horizontal'. | |||||
picture. Default: 10. | |||||
mode (str): Direction of deformation. Optional value is 'vertical' or 'horizontal'. Default: 'vertical'. | |||||
auto_param (bool): Auto selected parameters. Selected parameters will preserve semantics of image. | auto_param (bool): Auto selected parameters. Selected parameters will preserve semantics of image. | ||||
Default: False. | Default: False. | ||||
Examples: | Examples: | ||||
>>> import cv2 | |||||
>>> img = cv2.imread('x.png') | >>> img = cv2.imread('x.png') | ||||
>>> curves =1 | >>> curves =1 | ||||
>>> depth = 10 | >>> depth = 10 | ||||