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


Python augmenters.AverageBlur方法代码示例

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


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

示例1: test_kernel_size_is_tuple

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import AverageBlur [as 别名]
def test_kernel_size_is_tuple(self):
        # k as (3, 4)
        aug = iaa.AverageBlur(k=(3, 4))
        nb_iterations = 100
        nb_seen = [0, 0]
        for i in sm.xrange(nb_iterations):
            observed = aug.augment_image(self.base_img)
            if np.array_equal(observed, self.blur3x3):
                nb_seen[0] += 1
            elif np.array_equal(observed, self.blur4x4):
                nb_seen[1] += 1
            else:
                raise Exception("Unexpected result in AverageBlur@1")
        p_seen = [v/nb_iterations for v in nb_seen]
        assert 0.4 <= p_seen[0] <= 0.6
        assert 0.4 <= p_seen[1] <= 0.6 
开发者ID:aleju,项目名称:imgaug,代码行数:18,代码来源:test_blur.py

示例2: test_kernel_size_is_stochastic_parameter

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import AverageBlur [as 别名]
def test_kernel_size_is_stochastic_parameter(self):
        # k as stochastic parameter
        aug = iaa.AverageBlur(k=iap.Choice([3, 5]))
        nb_iterations = 100
        nb_seen = [0, 0]
        for i in sm.xrange(nb_iterations):
            observed = aug.augment_image(self.base_img)
            if np.array_equal(observed, self.blur3x3):
                nb_seen[0] += 1
            elif np.array_equal(observed, self.blur5x5):
                nb_seen[1] += 1
            else:
                raise Exception("Unexpected result in AverageBlur@3")
        p_seen = [v/nb_iterations for v in nb_seen]
        assert 0.4 <= p_seen[0] <= 0.6
        assert 0.4 <= p_seen[1] <= 0.6 
开发者ID:aleju,项目名称:imgaug,代码行数:18,代码来源:test_blur.py

示例3: test_kernel_size_is_tuple_of_tuples

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import AverageBlur [as 别名]
def test_kernel_size_is_tuple_of_tuples(self):
        # k as ((3, 5), (3, 5))
        aug = iaa.AverageBlur(k=((3, 5), (3, 5)))

        possible = dict()
        for kh in [3, 4, 5]:
            for kw in [3, 4, 5]:
                key = (kh, kw)
                if kh == 0 or kw == 0:
                    possible[key] = np.copy(self.base_img)
                else:
                    possible[key] = cv2.blur(
                        self.base_img, (kh, kw))[..., np.newaxis]

        nb_iterations = 250
        nb_seen = dict([(key, 0) for key, val in possible.items()])
        for i in sm.xrange(nb_iterations):
            observed = aug.augment_image(self.base_img)
            for key, img_aug in possible.items():
                if np.array_equal(observed, img_aug):
                    nb_seen[key] += 1
        # dont check sum here, because 0xX and Xx0 are all the same, i.e. much
        # higher sum than nb_iterations
        assert np.all([v > 0 for v in nb_seen.values()]) 
开发者ID:aleju,项目名称:imgaug,代码行数:26,代码来源:test_blur.py

示例4: test_zero_sized_axes

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import AverageBlur [as 别名]
def test_zero_sized_axes(self):
        shapes = [
            (0, 0),
            (0, 1),
            (1, 0),
            (0, 1, 0),
            (1, 0, 0),
            (0, 1, 1),
            (1, 0, 1)
        ]

        for shape in shapes:
            with self.subTest(shape=shape):
                image = np.zeros(shape, dtype=np.uint8)

                image_aug = iaa.AverageBlur(k=3)(image=image)

                assert image_aug.shape == image.shape 
开发者ID:aleju,项目名称:imgaug,代码行数:20,代码来源:test_blur.py

示例5: __init__

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

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import AverageBlur [as 别名]
def __init__(self, augmentation_rate):
        self.augs = iaa.Sometimes(
            augmentation_rate,
            iaa.SomeOf(
                (4, 7),
                [
                    iaa.Affine(rotate=(-10, 10)),
                    iaa.Fliplr(0.2),
                    iaa.AverageBlur(k=(2, 10)),
                    iaa.Add((-10, 10), per_channel=0.5),
                    iaa.Multiply((0.75, 1.25), per_channel=0.5),
                    iaa.ContrastNormalization((0.5, 2.0), per_channel=0.5),
                    iaa.Crop(px=(0, 20))
                ],
                random_order=True
            )
        ) 
开发者ID:Giphy,项目名称:celeb-detection-oss,代码行数:19,代码来源:img_augmentor.py

示例7: main

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

    k = [
        1,
        2,
        4,
        8,
        16,
        (8, 8),
        (1, 8),
        ((1, 1), (8, 8)),
        ((1, 16), (1, 16)),
        ((1, 16), 1)
    ]

    cv2.namedWindow("aug", cv2.WINDOW_NORMAL)
    cv2.resizeWindow("aug", 64*NB_AUGS_PER_IMAGE, 64)

    for ki in k:
        aug = iaa.AverageBlur(k=ki)
        img_aug = [aug.augment_image(image) for _ in range(NB_AUGS_PER_IMAGE)]
        img_aug = np.hstack(img_aug)
        print("dtype", img_aug.dtype, "averages", np.average(img_aug, axis=tuple(range(0, img_aug.ndim-1))))

        title = "k=%s" % (str(ki),)
        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,代码行数:35,代码来源:check_average_blur.py

示例8: test_kernel_size_0

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import AverageBlur [as 别名]
def test_kernel_size_0(self):
        # no blur, shouldnt change anything
        aug = iaa.AverageBlur(k=0)
        observed = aug.augment_image(self.base_img)
        assert np.array_equal(observed, self.base_img) 
开发者ID:aleju,项目名称:imgaug,代码行数:7,代码来源:test_blur.py

示例9: test_kernel_size_3

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import AverageBlur [as 别名]
def test_kernel_size_3(self):
        # k=3
        aug = iaa.AverageBlur(k=3)
        observed = aug.augment_image(self.base_img)
        assert np.array_equal(observed, self.blur3x3) 
开发者ID:aleju,项目名称:imgaug,代码行数:7,代码来源:test_blur.py

示例10: test_kernel_size_5

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import AverageBlur [as 别名]
def test_kernel_size_5(self):
        # k=5
        aug = iaa.AverageBlur(k=5)
        observed = aug.augment_image(self.base_img)
        assert np.array_equal(observed, self.blur5x5) 
开发者ID:aleju,项目名称:imgaug,代码行数:7,代码来源:test_blur.py

示例11: test_more_than_four_channels

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import AverageBlur [as 别名]
def test_more_than_four_channels(self):
        shapes = [
            (1, 1, 4),
            (1, 1, 5),
            (1, 1, 512),
            (1, 1, 513)
        ]
        for shape in shapes:
            with self.subTest(shape=shape):
                image = np.zeros(shape, dtype=np.uint8)

                image_aug = iaa.AverageBlur(k=3)(image=image)

                assert image_aug.shape == image.shape 
开发者ID:aleju,项目名称:imgaug,代码行数:16,代码来源:test_blur.py

示例12: test_keypoints_dont_change

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import AverageBlur [as 别名]
def test_keypoints_dont_change(self):
        kps = [ia.Keypoint(x=0, y=0), ia.Keypoint(x=1, y=1),
               ia.Keypoint(x=2, y=2)]
        kpsoi = [ia.KeypointsOnImage(kps, shape=(11, 11, 1))]

        aug = iaa.AverageBlur(k=3)
        aug_det = aug.to_deterministic()
        observed = aug.augment_keypoints(kpsoi)
        expected = kpsoi
        assert keypoints_equal(observed, expected)

        observed = aug_det.augment_keypoints(kpsoi)
        expected = kpsoi
        assert keypoints_equal(observed, expected) 
开发者ID:aleju,项目名称:imgaug,代码行数:16,代码来源:test_blur.py

示例13: test_failure_on_invalid_dtypes

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import AverageBlur [as 别名]
def test_failure_on_invalid_dtypes(self):
        # assert failure on invalid dtypes
        aug = iaa.AverageBlur(k=3)
        for dt in [np.uint32, np.uint64, np.int32, np.int64]:
            got_exception = False
            try:
                _ = aug.augment_image(np.zeros((1, 1), dtype=dt))
            except Exception as exc:
                assert "forbidden dtype" in str(exc)
                got_exception = True
            assert got_exception 
开发者ID:aleju,项目名称:imgaug,代码行数:13,代码来源:test_blur.py

示例14: test_pickleable

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import AverageBlur [as 别名]
def test_pickleable(self):
        aug = iaa.AverageBlur((1, 11), seed=1)
        runtest_pickleable_uint8_img(aug, iterations=10) 
开发者ID:aleju,项目名称:imgaug,代码行数:5,代码来源:test_blur.py

示例15: main

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

    k = [
        1,
        2,
        4,
        8,
        16,
        (8, 8),
        (1, 8),
        ((1, 1), (8, 8)),
        ((1, 16), (1, 16)),
        ((1, 16), 1)
    ]

    cv2.namedWindow("aug", cv2.WINDOW_NORMAL)
    cv2.resizeWindow("aug", 64*NB_AUGS_PER_IMAGE, 64)
    #cv2.imshow("aug", image[..., ::-1])
    #cv2.waitKey(TIME_PER_STEP)

    for ki in k:
        aug = iaa.AverageBlur(k=ki)
        img_aug = [aug.augment_image(image) for _ in range(NB_AUGS_PER_IMAGE)]
        img_aug = np.hstack(img_aug)
        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 = "k=%s" % (str(ki),)
        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,代码行数:38,代码来源:check_average_blur.py


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