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


Python augmenters.WithChannels方法代码示例

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


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

示例1: example_withchannels

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import WithChannels [as 别名]
def example_withchannels():
    print("Example: WithChannels")
    import numpy as np
    import imgaug.augmenters as iaa

    # fake RGB images
    images = np.random.randint(0, 255, (16, 128, 128, 3), dtype=np.uint8)

    # add a random value from the range (-30, 30) to the first two channels of
    # input images (e.g. to the R and G channels)
    aug = iaa.WithChannels(
      channels=[0, 1],
      children=iaa.Add((-30, 30))
    )

    images_aug = aug(images=images) 
开发者ID:aleju,项目名称:imgaug,代码行数:18,代码来源:check_readme_examples.py

示例2: main

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import WithChannels [as 别名]
def main():
    image = data.astronaut()
    print("image shape:", image.shape)

    aug = iaa.WithColorspace(
        from_colorspace="RGB",
        to_colorspace="HSV",
        children=iaa.WithChannels(0, iaa.Add(50))
    )

    aug_no_colorspace = iaa.WithChannels(0, iaa.Add(50))

    img_show = np.hstack([
        image,
        aug.augment_image(image),
        aug_no_colorspace.augment_image(image)
    ])
    ia.imshow(img_show) 
开发者ID:aleju,项目名称:imgaug,代码行数:20,代码来源:check_withcolorspace.py

示例3: test_returns_correct_class

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import WithChannels [as 别名]
def test_returns_correct_class(self):
        # this test is practically identical to
        # TestMultiplyToHueAndSaturation
        #     .test_returns_correct_objects__mul_saturation
        aug = iaa.MultiplySaturation((0.9, 1.1))
        assert isinstance(aug, iaa.WithHueAndSaturation)
        assert isinstance(aug.children, iaa.Sequential)
        assert len(aug.children) == 1
        assert isinstance(aug.children[0], iaa.WithChannels)
        assert aug.children[0].channels == [1]
        assert len(aug.children[0].children) == 1
        assert isinstance(aug.children[0].children[0], iaa.Multiply)
        assert is_parameter_instance(aug.children[0].children[0].mul,
                                     iap.Uniform)
        assert np.isclose(aug.children[0].children[0].mul.a.value, 0.9)
        assert np.isclose(aug.children[0].children[0].mul.b.value, 1.1) 
开发者ID:aleju,项目名称:imgaug,代码行数:18,代码来源:test_color.py

示例4: main

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import WithChannels [as 别名]
def main():
    image = data.astronaut()
    print("image shape:", image.shape)

    aug = iaa.WithColorspace(
        from_colorspace="RGB",
        to_colorspace="HSV",
        children=iaa.WithChannels(0, iaa.Add(50))
    )

    aug_no_colorspace = iaa.WithChannels(0, iaa.Add(50))

    img_show = np.hstack([
        image,
        aug.augment_image(image),
        aug_no_colorspace.augment_image(image)
    ])
    misc.imshow(img_show) 
开发者ID:JoshuaPiinRueyPan,项目名称:ViolenceDetection,代码行数:20,代码来源:check_withcolorspace.py

示例5: __init__

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import WithChannels [as 别名]
def __init__(self,data_dir, back_dir,
                 batch_size=50,gan=True,imsize=128,
                 res_x=640,res_y=480,
                 **kwargs):
        '''
        data_dir: Folder that contains cropped image+xyz
        back_dir: Folder that contains random background images
            batch_size: batch size for training
        gan: if False, gt for GAN is not yielded
        '''
        self.data_dir = data_dir
        self.back_dir = back_dir
        self.imsize=imsize
        self.batch_size = batch_size
        self.gan = gan
        self.backfiles = os.listdir(back_dir)
        data_list = os.listdir(data_dir)
        self.datafiles=[]
        self.res_x=res_x
        self.res_y=res_y

        for file in data_list:
            if(file.endswith(".npy")):
                self.datafiles.append(file)

        self.n_data = len(self.datafiles)
        self.n_background = len(self.backfiles)
        print("Total training views:", self.n_data)

        self.seq_syn= iaa.Sequential([
                                    iaa.WithChannels(0, iaa.Add((-15, 15))),
                                    iaa.WithChannels(1, iaa.Add((-15, 15))),
                                    iaa.WithChannels(2, iaa.Add((-15, 15))),
                                    iaa.ContrastNormalization((0.8, 1.3)),
                                    iaa.Multiply((0.8, 1.2),per_channel=0.5),
                                    iaa.GaussianBlur(sigma=(0.0, 0.5)),
                                    iaa.Sometimes(0.1, iaa.AdditiveGaussianNoise(scale=10, per_channel=True)),
                                    iaa.Sometimes(0.5, iaa.ContrastNormalization((0.5, 2.2), per_channel=0.3)),
                                    ], random_order=True) 
开发者ID:kirumang,项目名称:Pix2Pose,代码行数:41,代码来源:data_io.py

示例6: main

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import WithChannels [as 别名]
def main():
    image = data.astronaut()
    print("image shape:", image.shape)
    print("Press ENTER or wait %d ms to proceed to the next image." % (TIME_PER_STEP,))

    children_all = [
        ("hflip", iaa.Fliplr(1)),
        ("add", iaa.Add(50)),
        ("dropout", iaa.Dropout(0.2)),
        ("affine", iaa.Affine(rotate=35))
    ]

    channels_all = [
        None,
        0,
        [],
        [0],
        [0, 1],
        [1, 2],
        [0, 1, 2]
    ]

    cv2.namedWindow("aug", cv2.WINDOW_NORMAL)
    cv2.imshow("aug", image[..., ::-1])
    cv2.waitKey(TIME_PER_STEP)

    for children_title, children in children_all:
        for channels in channels_all:
            aug = iaa.WithChannels(channels=channels, children=children)
            img_aug = aug.augment_image(image)
            print("dtype", img_aug.dtype, "averages", np.average(img_aug, axis=tuple(range(0, img_aug.ndim-1))))

            title = "children=%s | channels=%s" % (children_title, channels)
            img_aug = ia.draw_text(img_aug, x=5, y=5, text=title)

            cv2.imshow("aug", img_aug[..., ::-1])  # here with rgb2bgr
            cv2.waitKey(TIME_PER_STEP) 
开发者ID:aleju,项目名称:imgaug,代码行数:39,代码来源:check_withchannels.py

示例7: test_returns_correct_objects__mul_hue

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import WithChannels [as 别名]
def test_returns_correct_objects__mul_hue(self):
        aug = iaa.MultiplyHueAndSaturation(mul_hue=(0.9, 1.1))
        assert isinstance(aug, iaa.WithHueAndSaturation)
        assert isinstance(aug.children, iaa.Sequential)
        assert len(aug.children) == 1
        assert isinstance(aug.children[0], iaa.WithChannels)
        assert aug.children[0].channels == [0]
        assert len(aug.children[0].children) == 1
        assert isinstance(aug.children[0].children[0], iaa.Multiply)
        assert is_parameter_instance(aug.children[0].children[0].mul,
                                     iap.Uniform)
        assert np.isclose(aug.children[0].children[0].mul.a.value, 0.9)
        assert np.isclose(aug.children[0].children[0].mul.b.value, 1.1) 
开发者ID:aleju,项目名称:imgaug,代码行数:15,代码来源:test_color.py

示例8: test_returns_correct_objects__mul_saturation

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import WithChannels [as 别名]
def test_returns_correct_objects__mul_saturation(self):
        aug = iaa.MultiplyHueAndSaturation(mul_saturation=(0.9, 1.1))
        assert isinstance(aug, iaa.WithHueAndSaturation)
        assert isinstance(aug.children, iaa.Sequential)
        assert len(aug.children) == 1
        assert isinstance(aug.children[0], iaa.WithChannels)
        assert aug.children[0].channels == [1]
        assert len(aug.children[0].children) == 1
        assert isinstance(aug.children[0].children[0], iaa.Multiply)
        assert is_parameter_instance(aug.children[0].children[0].mul,
                                     iap.Uniform)
        assert np.isclose(aug.children[0].children[0].mul.a.value, 0.9)
        assert np.isclose(aug.children[0].children[0].mul.b.value, 1.1) 
开发者ID:aleju,项目名称:imgaug,代码行数:15,代码来源:test_color.py

示例9: main

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import WithChannels [as 别名]
def main():
    image = data.astronaut()
    print("image shape:", image.shape)
    print("Press any key or wait %d ms to proceed to the next image." % (TIME_PER_STEP,))

    children_all = [
        ("hflip", iaa.Fliplr(1)),
        ("add", iaa.Add(50)),
        ("dropout", iaa.Dropout(0.2)),
        ("affine", iaa.Affine(rotate=35))
    ]

    channels_all = [
        None,
        0,
        [],
        [0],
        [0, 1],
        [1, 2],
        [0, 1, 2]
    ]

    cv2.namedWindow("aug", cv2.WINDOW_NORMAL)
    cv2.imshow("aug", image[..., ::-1])
    cv2.waitKey(TIME_PER_STEP)

    for children_title, children in children_all:
        for channels in channels_all:
            aug = iaa.WithChannels(channels=channels, children=children)
            img_aug = aug.augment_image(image)
            print("dtype", img_aug.dtype, "averages", np.average(img_aug, axis=tuple(range(0, img_aug.ndim-1))))
            #print("dtype", img_aug.dtype, "averages", img_aug.mean(axis=range(1, img_aug.ndim)))

            title = "children=%s | channels=%s" % (children_title, channels)
            img_aug = ia.draw_text(img_aug, x=5, y=5, text=title)

            cv2.imshow("aug", img_aug[..., ::-1]) # here with rgb2bgr
            cv2.waitKey(TIME_PER_STEP) 
开发者ID:JoshuaPiinRueyPan,项目名称:ViolenceDetection,代码行数:40,代码来源:check_withchannels.py

示例10: chapter_augmenters_withcolorspace

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import WithChannels [as 别名]
def chapter_augmenters_withcolorspace():
    aug = iaa.WithColorspace(
        to_colorspace="HSV",
        from_colorspace="RGB",
        children=iaa.WithChannels(0, iaa.Add((10, 50)))
    )
    run_and_save_augseq(
        "withcolorspace.jpg", aug,
        [ia.quokka(size=(128, 128)) for _ in range(8)], cols=4, rows=2
    ) 
开发者ID:JoshuaPiinRueyPan,项目名称:ViolenceDetection,代码行数:12,代码来源:generate_documentation_images.py

示例11: chapter_augmenters_withchannels

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import WithChannels [as 别名]
def chapter_augmenters_withchannels():
    aug = iaa.WithChannels(0, iaa.Add((10, 100)))
    run_and_save_augseq(
        "withchannels.jpg", aug,
        [ia.quokka(size=(128, 128)) for _ in range(8)], cols=4, rows=2
    )

    aug = iaa.WithChannels(0, iaa.Affine(rotate=(0, 45)))
    run_and_save_augseq(
        "withchannels_affine.jpg", aug,
        [ia.quokka(size=(128, 128)) for _ in range(8)], cols=4, rows=2
    ) 
开发者ID:JoshuaPiinRueyPan,项目名称:ViolenceDetection,代码行数:14,代码来源:generate_documentation_images.py

示例12: chapter_augmenters_changecolorspace

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import WithChannels [as 别名]
def chapter_augmenters_changecolorspace():
    aug = iaa.Sequential([
        iaa.ChangeColorspace(from_colorspace="RGB", to_colorspace="HSV"),
        iaa.WithChannels(0, iaa.Add((50, 100))),
        iaa.ChangeColorspace(from_colorspace="HSV", to_colorspace="RGB")
    ])
    run_and_save_augseq(
        "changecolorspace.jpg", aug,
        [ia.quokka(size=(128, 128)) for _ in range(8)], cols=4, rows=2
    ) 
开发者ID:JoshuaPiinRueyPan,项目名称:ViolenceDetection,代码行数:12,代码来源:generate_documentation_images.py


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