当前位置: 首页>>代码示例>>Python>>正文


Python image.apply_affine_transform方法代码示例

本文整理汇总了Python中keras_preprocessing.image.apply_affine_transform方法的典型用法代码示例。如果您正苦于以下问题:Python image.apply_affine_transform方法的具体用法?Python image.apply_affine_transform怎么用?Python image.apply_affine_transform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在keras_preprocessing.image的用法示例。


在下文中一共展示了image.apply_affine_transform方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: random_zoom

# 需要导入模块: from keras_preprocessing import image [as 别名]
# 或者: from keras_preprocessing.image import apply_affine_transform [as 别名]
def random_zoom(image, label, zoom_range):
    if np.ndim(label) == 2:
        label = np.expand_dims(label, axis=-1)
    assert np.ndim(label) == 3

    if np.isscalar(zoom_range):
        zx, zy = np.random.uniform(1 - zoom_range, 1 + zoom_range, 2)
    elif len(zoom_range) == 2:
        zx, zy = np.random.uniform(zoom_range[0], zoom_range[1], 2)
    else:
        raise ValueError('`zoom_range` should be a float or '
                         'a tuple or list of two floats. '
                         'Received: %s' % (zoom_range,))

    image = keras_image.apply_affine_transform(image, zx=zx, zy=zy, fill_mode='nearest')
    label = keras_image.apply_affine_transform(label, zx=zx, zy=zy, fill_mode='nearest')

    return image, label 
开发者ID:luyanger1799,项目名称:Amazing-Semantic-Segmentation,代码行数:20,代码来源:utils.py

示例2: random_rotate

# 需要导入模块: from keras_preprocessing import image [as 别名]
# 或者: from keras_preprocessing.image import apply_affine_transform [as 别名]
def random_rotate(img, mask, rotate_limit=(-20, 20), u=0.5):
    if np.random.random() < u:
        theta = np.random.uniform(rotate_limit[0], rotate_limit[1])
        img = image.apply_affine_transform(img, theta=theta)
        mask = image.apply_affine_transform(mask, theta=theta)
    return img, mask 
开发者ID:CVxTz,项目名称:medical_image_segmentation,代码行数:8,代码来源:aug_utils.py

示例3: shift

# 需要导入模块: from keras_preprocessing import image [as 别名]
# 或者: from keras_preprocessing.image import apply_affine_transform [as 别名]
def shift(x, wshift, hshift, row_axis=0, col_axis=1, channel_axis=2, fill_mode='nearest', cval=0.):
    h, w = x.shape[row_axis], x.shape[col_axis]
    tx = hshift * h
    ty = wshift * w
    x = image.apply_affine_transform(x, ty=ty, tx=tx)
    return x 
开发者ID:CVxTz,项目名称:medical_image_segmentation,代码行数:8,代码来源:aug_utils.py

示例4: random_zoom

# 需要导入模块: from keras_preprocessing import image [as 别名]
# 或者: from keras_preprocessing.image import apply_affine_transform [as 别名]
def random_zoom(img, mask, zoom_range=(0.8, 1), u=0.5):
    if np.random.random() < u:
        zx, zy = np.random.uniform(zoom_range[0], zoom_range[1], 2)
        img = image.apply_affine_transform(img, zx=zx, zy=zy)
        mask = image.apply_affine_transform(mask, zx=zx, zy=zy)
    return img, mask 
开发者ID:CVxTz,项目名称:medical_image_segmentation,代码行数:8,代码来源:aug_utils.py

示例5: random_shear

# 需要导入模块: from keras_preprocessing import image [as 别名]
# 或者: from keras_preprocessing.image import apply_affine_transform [as 别名]
def random_shear(img, mask, intensity_range=(-0.5, 0.5), u=0.5):
    if np.random.random() < u:
        sh = np.random.uniform(-intensity_range[0], intensity_range[1])
        img = image.apply_affine_transform(img, shear=sh)
        mask = image.apply_affine_transform(mask, shear=sh)
    return img, mask 
开发者ID:CVxTz,项目名称:medical_image_segmentation,代码行数:8,代码来源:aug_utils.py

示例6: random_rotation

# 需要导入模块: from keras_preprocessing import image [as 别名]
# 或者: from keras_preprocessing.image import apply_affine_transform [as 别名]
def random_rotation(image, label, rotation_range):
    if np.ndim(label) == 2:
        label = np.expand_dims(label, axis=-1)
    assert np.ndim(label) == 3

    if rotation_range > 0.:
        theta = np.random.uniform(-rotation_range, rotation_range)
        # rotate it!
        image = keras_image.apply_affine_transform(image, theta=theta, fill_mode='nearest')
        label = keras_image.apply_affine_transform(label, theta=theta, fill_mode='nearest')
    return image, label 
开发者ID:luyanger1799,项目名称:Amazing-Semantic-Segmentation,代码行数:13,代码来源:utils.py

示例7: keras

# 需要导入模块: from keras_preprocessing import image [as 别名]
# 或者: from keras_preprocessing.image import apply_affine_transform [as 别名]
def keras(self, img):
        img = keras.apply_affine_transform(img, theta=45, channel_axis=2, fill_mode="reflect")
        return np.ascontiguousarray(img) 
开发者ID:albumentations-team,项目名称:albumentations,代码行数:5,代码来源:benchmark.py


注:本文中的keras_preprocessing.image.apply_affine_transform方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。