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


Python augmenters.GaussianBlur方法代码示例

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


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

示例1: _load_augmentation_aug_non_geometric

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import GaussianBlur [as 别名]
def _load_augmentation_aug_non_geometric():
    return iaa.Sequential([
        iaa.Sometimes(0.3, iaa.Multiply((0.5, 1.5), per_channel=0.5)),
        iaa.Sometimes(0.2, iaa.JpegCompression(compression=(70, 99))),
        iaa.Sometimes(0.2, iaa.GaussianBlur(sigma=(0, 3.0))),
        iaa.Sometimes(0.2, iaa.MotionBlur(k=15, angle=[-45, 45])),
        iaa.Sometimes(0.2, iaa.MultiplyHue((0.5, 1.5))),
        iaa.Sometimes(0.2, iaa.MultiplySaturation((0.5, 1.5))),
        iaa.Sometimes(0.34, iaa.MultiplyHueAndSaturation((0.5, 1.5),
                                                         per_channel=True)),
        iaa.Sometimes(0.34, iaa.Grayscale(alpha=(0.0, 1.0))),
        iaa.Sometimes(0.2, iaa.ChangeColorTemperature((1100, 10000))),
        iaa.Sometimes(0.1, iaa.GammaContrast((0.5, 2.0))),
        iaa.Sometimes(0.2, iaa.SigmoidContrast(gain=(3, 10),
                                               cutoff=(0.4, 0.6))),
        iaa.Sometimes(0.1, iaa.CLAHE()),
        iaa.Sometimes(0.1, iaa.HistogramEqualization()),
        iaa.Sometimes(0.2, iaa.LinearContrast((0.5, 2.0), per_channel=0.5)),
        iaa.Sometimes(0.1, iaa.Emboss(alpha=(0, 1.0), strength=(0, 2.0)))
    ]) 
开发者ID:divamgupta,项目名称:image-segmentation-keras,代码行数:22,代码来源:augmentation.py

示例2: example_augment_images_and_heatmaps

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import GaussianBlur [as 别名]
def example_augment_images_and_heatmaps():
    print("Example: Augment Images and Heatmaps")
    import numpy as np
    import imgaug.augmenters as iaa

    # Standard scenario: You have N RGB-images and additionally 21 heatmaps per
    # image. You want to augment each image and its heatmaps identically.
    images = np.random.randint(0, 255, (16, 128, 128, 3), dtype=np.uint8)
    heatmaps = np.random.random(size=(16, 64, 64, 1)).astype(np.float32)

    seq = iaa.Sequential([
        iaa.GaussianBlur((0, 3.0)),
        iaa.Affine(translate_px={"x": (-40, 40)}),
        iaa.Crop(px=(0, 10))
    ])

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

示例3: example_augment_images_and_segmentation_maps

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import GaussianBlur [as 别名]
def example_augment_images_and_segmentation_maps():
    print("Example: Augment Images and Segmentation Maps")
    import numpy as np
    import imgaug.augmenters as iaa

    # Standard scenario: You have N=16 RGB-images and additionally one segmentation
    # map per image. You want to augment each image and its heatmaps identically.
    images = np.random.randint(0, 255, (16, 128, 128, 3), dtype=np.uint8)
    segmaps = np.random.randint(0, 10, size=(16, 64, 64, 1), dtype=np.int32)

    seq = iaa.Sequential([
        iaa.GaussianBlur((0, 3.0)),
        iaa.Affine(translate_px={"x": (-40, 40)}),
        iaa.Crop(px=(0, 10))
    ])

    images_aug, segmaps_aug = seq(images=images, segmentation_maps=segmaps) 
开发者ID:aleju,项目名称:imgaug,代码行数:19,代码来源:check_readme_examples.py

示例4: test_backends_called

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import GaussianBlur [as 别名]
def test_backends_called(self):
        def side_effect_cv2(image, ksize, sigmaX, sigmaY, borderType):
            return image + 1

        def side_effect_scipy(image, sigma, mode):
            return image + 1

        mock_GaussianBlur = mock.Mock(side_effect=side_effect_cv2)
        mock_gaussian_filter = mock.Mock(side_effect=side_effect_scipy)
        image = np.arange(4*4).astype(np.uint8).reshape((4, 4))
        with mock.patch('cv2.GaussianBlur', mock_GaussianBlur):
            _observed = iaa.blur_gaussian_(
                np.copy(image), sigma=1.0, eps=0, backend="cv2")
        assert mock_GaussianBlur.call_count == 1

        with mock.patch('scipy.ndimage.gaussian_filter', mock_gaussian_filter):
            _observed = iaa.blur_gaussian_(
                np.copy(image), sigma=1.0, eps=0, backend="scipy")
        assert mock_gaussian_filter.call_count == 1 
开发者ID:aleju,项目名称:imgaug,代码行数:21,代码来源:test_blur.py

示例5: __init__

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import GaussianBlur [as 别名]
def __init__(self):
        self.seq = iaa.Sequential([
            iaa.Sometimes(0.5, iaa.OneOf([
                iaa.GaussianBlur((0, 3.0)),  # blur images with a sigma between 0 and 3.0
                iaa.AverageBlur(k=(2, 7)),  # blur image using local means with kernel sizes between 2 and 7
                iaa.MedianBlur(k=(3, 11)),  # blur image using local medians with kernel sizes between 2 and 7
            ])),
            iaa.Sometimes(0.5, iaa.AdditiveGaussianNoise(loc=0, scale=(0.0, 0.05 * 255), per_channel=0.5)),
            iaa.Sometimes(0.5, iaa.Add((-10, 10), per_channel=0.5)),
            iaa.Sometimes(0.5, iaa.AddToHueAndSaturation((-20, 20))),
            iaa.Sometimes(0.5, iaa.FrequencyNoiseAlpha(
                exponent=(-4, 0),
                first=iaa.Multiply((0.5, 1.5), per_channel=True),
                second=iaa.LinearContrast((0.5, 2.0))
            )),
            iaa.Sometimes(0.5, iaa.PiecewiseAffine(scale=(0.01, 0.05))),
            iaa.Sometimes(0.5, iaa.PerspectiveTransform(scale=(0.01, 0.1)))
        ], random_order=True) 
开发者ID:WenmuZhou,项目名称:crnn.gluon,代码行数:20,代码来源:augment.py

示例6: create_augmenter

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import GaussianBlur [as 别名]
def create_augmenter(stage: str = "train"):
        if stage == "train":
            return iaa.Sequential([
                iaa.Fliplr(0.5),
                iaa.CropAndPad(px=(0, 112), sample_independently=False),
                iaa.Affine(translate_percent={"x": (-0.4, 0.4), "y": (-0.4, 0.4)}),
                iaa.SomeOf((0, 3), [
                    iaa.AddToHueAndSaturation((-10, 10)),
                    iaa.Affine(scale={"x": (0.9, 1.1), "y": (0.9, 1.1)}),
                    iaa.GaussianBlur(sigma=(0, 1.0)),
                    iaa.AdditiveGaussianNoise(scale=0.05 * 255)
                ])
            ])
        elif stage == "val":
            return iaa.Sequential([
                iaa.CropAndPad(px=(0, 112), sample_independently=False),
                iaa.Affine(translate_percent={"x": (-0.4, 0.4), "y": (-0.4, 0.4)}),
            ])
        elif stage == "test":
            return iaa.Sequential([]) 
开发者ID:csvance,项目名称:keras-mobile-detectnet,代码行数:22,代码来源:generator.py

示例7: init_augmentations

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import GaussianBlur [as 别名]
def init_augmentations(self):
        if self.transform_probability > 0 and self.use_imgaug:
            augmentations = iaa.Sometimes(
                self.transform_probability,
                iaa.Sequential([
                    iaa.SomeOf(
                        (1, None),
                        [
                            iaa.AddToHueAndSaturation(iap.Uniform(-20, 20), per_channel=True),
                            iaa.GaussianBlur(sigma=(0, 1.0)),
                            iaa.LinearContrast((0.75, 1.0)),
                            iaa.PiecewiseAffine(scale=(0.01, 0.02), mode='edge'),
                        ],
                        random_order=True
                    ),
                    iaa.Resize(
                        {"height": (16, self.image_size.height), "width": "keep-aspect-ratio"},
                        interpolation=imgaug.ALL
                    ),
                ])
            )
        else:
            augmentations = None
        return augmentations 
开发者ID:Bartzi,项目名称:kiss,代码行数:26,代码来源:image_dataset.py

示例8: amaugimg

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import GaussianBlur [as 别名]
def amaugimg(image):
    #数据增强
    image = cv2.cvtColor(np.asarray(image), cv2.COLOR_RGB2BGR)

    seq = iaa.Sequential([
        # iaa.Affine(rotate=(-5, 5),
        #            shear=(-5, 5),
        #            mode='edge'),

        iaa.SomeOf((0, 2),                        #选择数据增强
                   [
                       iaa.GaussianBlur((0, 1.5)),
                       iaa.AdditiveGaussianNoise(loc=0, scale=(0.0, 0.01 * 255), per_channel=0.5),
                       # iaa.AddToHueAndSaturation((-5, 5)),  # change hue and saturation
                       iaa.PiecewiseAffine(scale=(0.01, 0.03)),
                       iaa.PerspectiveTransform(scale=(0.01, 0.1))
                   ],
                   random_order=True
                   )
    ])
    image = seq.augment_image(image)

    image = Image.fromarray(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))
    return image 
开发者ID:LcenArthas,项目名称:CVWC2019-Amur-Tiger-Re-ID,代码行数:26,代码来源:dataset_loader.py

示例9: chapter_augmenters_sometimes

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import GaussianBlur [as 别名]
def chapter_augmenters_sometimes():
    aug = iaa.Sometimes(0.5, iaa.GaussianBlur(sigma=2.0))
    run_and_save_augseq(
        "sometimes.jpg", aug,
        [ia.quokka(size=(64, 64)) for _ in range(16)], cols=8, rows=2,
        seed=2
    )

    aug = iaa.Sometimes(
        0.5,
        iaa.GaussianBlur(sigma=2.0),
        iaa.Sequential([iaa.Affine(rotate=45), iaa.Sharpen(alpha=1.0)])
    )
    run_and_save_augseq(
        "sometimes_if_else.jpg", aug,
        [ia.quokka(size=(64, 64)) for _ in range(16)], cols=8, rows=2
    ) 
开发者ID:JoshuaPiinRueyPan,项目名称:ViolenceDetection,代码行数:19,代码来源:generate_documentation_images.py

示例10: example_show

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import GaussianBlur [as 别名]
def example_show():
    print("Example: Show")
    from imgaug import augmenters as iaa

    images = np.random.randint(0, 255, (16, 128, 128, 3), dtype=np.uint8)
    seq = iaa.Sequential([iaa.Fliplr(0.5), iaa.GaussianBlur((0, 3.0))])

    # show an image with 8*8 augmented versions of image 0
    seq.show_grid(images[0], cols=8, rows=8)

    # Show an image with 8*8 augmented versions of image 0 and 8*8 augmented
    # versions of image 1. The identical augmentations will be applied to
    # image 0 and 1.
    seq.show_grid([images[0], images[1]], cols=8, rows=8)

# this example is no longer necessary as the library can now handle 2D images 
开发者ID:JoshuaPiinRueyPan,项目名称:ViolenceDetection,代码行数:18,代码来源:test_readme_examples.py

示例11: example_single_augmenters

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import GaussianBlur [as 别名]
def example_single_augmenters():
    print("Example: Single Augmenters")
    from imgaug import augmenters as iaa
    images = np.random.randint(0, 255, (16, 128, 128, 3), dtype=np.uint8)

    flipper = iaa.Fliplr(1.0) # always horizontally flip each input image
    images[0] = flipper.augment_image(images[0]) # horizontally flip image 0

    vflipper = iaa.Flipud(0.9) # vertically flip each input image with 90% probability
    images[1] = vflipper.augment_image(images[1]) # probably vertically flip image 1

    blurer = iaa.GaussianBlur(3.0)
    images[2] = blurer.augment_image(images[2]) # blur image 2 by a sigma of 3.0
    images[3] = blurer.augment_image(images[3]) # blur image 3 by a sigma of 3.0 too

    translater = iaa.Affine(translate_px={"x": -16}) # move each input image by 16px to the left
    images[4] = translater.augment_image(images[4]) # move image 4 to the left

    scaler = iaa.Affine(scale={"y": (0.8, 1.2)}) # scale each input image to 80-120% on the y axis
    images[5] = scaler.augment_image(images[5]) # scale image 5 by 80-120% on the y axis 
开发者ID:JoshuaPiinRueyPan,项目名称:ViolenceDetection,代码行数:22,代码来源:test_readme_examples.py

示例12: __init__

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import GaussianBlur [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

示例13: example_simple_training_setting

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

    def load_batch(batch_idx):
        # dummy function, implement this
        # Return a numpy array of shape (N, height, width, #channels)
        # or a list of (height, width, #channels) arrays (may have different image
        # sizes).
        # Images should be in RGB for colorspace augmentations.
        # (cv2.imread() returns BGR!)
        # Images should usually be in uint8 with values from 0-255.
        return np.zeros((128, 32, 32, 3), dtype=np.uint8) + (batch_idx % 255)

    def train_on_images(images):
        # dummy function, implement this
        pass

    # Pipeline:
    # (1) Crop images from each side by 1-16px, do not resize the results
    #     images back to the input size. Keep them at the cropped size.
    # (2) Horizontally flip 50% of the images.
    # (3) Blur images using a gaussian kernel with sigma between 0.0 and 3.0.
    seq = iaa.Sequential([
        iaa.Crop(px=(1, 16), keep_size=False),
        iaa.Fliplr(0.5),
        iaa.GaussianBlur(sigma=(0, 3.0))
    ])

    for batch_idx in range(100):
        images = load_batch(batch_idx)
        images_aug = seq(images=images)  # done by the library
        train_on_images(images_aug)

        # -----
        # Make sure that the example really does something
        if batch_idx == 0:
            assert not np.array_equal(images, images_aug) 
开发者ID:aleju,项目名称:imgaug,代码行数:41,代码来源:check_readme_examples.py

示例14: example_visualize_augmented_images

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

    images = np.random.randint(0, 255, (16, 128, 128, 3), dtype=np.uint8)
    seq = iaa.Sequential([iaa.Fliplr(0.5), iaa.GaussianBlur((0, 3.0))])

    # Show an image with 8*8 augmented versions of image 0 and 8*8 augmented
    # versions of image 1. Identical augmentations will be applied to
    # image 0 and 1.
    seq.show_grid([images[0], images[1]], cols=8, rows=8) 
开发者ID:aleju,项目名称:imgaug,代码行数:14,代码来源:check_readme_examples.py

示例15: example_using_augmenters_only_once

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import GaussianBlur [as 别名]
def example_using_augmenters_only_once():
    print("Example: Using Augmenters Only Once")
    from imgaug import augmenters as iaa
    import numpy as np

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

    # always horizontally flip each input image
    images_aug = iaa.Fliplr(1.0)(images=images)

    # vertically flip each input image with 90% probability
    images_aug = iaa.Flipud(0.9)(images=images)

    # blur 50% of all images using a gaussian kernel with a sigma of 3.0
    images_aug = iaa.Sometimes(0.5, iaa.GaussianBlur(3.0))(images=images) 
开发者ID:aleju,项目名称:imgaug,代码行数:17,代码来源:check_readme_examples.py


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