本文整理汇总了Python中imgaug.augmenters.Emboss方法的典型用法代码示例。如果您正苦于以下问题:Python augmenters.Emboss方法的具体用法?Python augmenters.Emboss怎么用?Python augmenters.Emboss使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类imgaug.augmenters
的用法示例。
在下文中一共展示了augmenters.Emboss方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _load_augmentation_aug_non_geometric
# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Emboss [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)))
])
示例2: chapter_augmenters_emboss
# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Emboss [as 别名]
def chapter_augmenters_emboss():
aug = iaa.Emboss(alpha=(0.0, 1.0), strength=(0.5, 1.5))
run_and_save_augseq(
"emboss.jpg", aug,
[ia.quokka(size=(64, 64)) for _ in range(16)], cols=8, rows=2
)
#alphas = [1/8*i for i in range(8)]
alphas = np.linspace(0, 1.0, num=8)
run_and_save_augseq(
"emboss_vary_alpha.jpg",
[iaa.Emboss(alpha=alpha, strength=1.0) for alpha in alphas],
[ia.quokka(size=(64, 64)) for _ in range(8)], cols=8, rows=1
)
#strengths = [0.5+(0.5/8)*i for i in range(8)]
strengths = np.linspace(0.5, 1.5, num=8)
run_and_save_augseq(
"emboss_vary_strength.jpg",
[iaa.Emboss(alpha=1.0, strength=strength) for strength in strengths],
[ia.quokka(size=(64, 64)) for _ in range(8)], cols=8, rows=1
)
示例3: test_alpha_0_strength_1
# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Emboss [as 别名]
def test_alpha_0_strength_1(self):
aug = iaa.Emboss(alpha=0, strength=1)
observed = aug.augment_image(self.base_img)
expected = self.base_img
assert self._allclose(observed, expected)
示例4: test_alpha_1_strength_1
# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Emboss [as 别名]
def test_alpha_1_strength_1(self):
aug = iaa.Emboss(alpha=1.0, strength=1)
observed = aug.augment_image(self.base_img)
expected = self._compute_embossed_base_img(
self.base_img, alpha=1.0, strength=1)
assert self._allclose(observed, expected)
示例5: test_alpha_050_strength_1
# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Emboss [as 别名]
def test_alpha_050_strength_1(self):
aug = iaa.Emboss(alpha=0.5, strength=1)
observed = aug.augment_image(self.base_img)
expected = self._compute_embossed_base_img(
self.base_img, alpha=0.5, strength=1)
assert self._allclose(observed, expected.astype(np.uint8))
示例6: test_alpha_075_strength_1
# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Emboss [as 别名]
def test_alpha_075_strength_1(self):
aug = iaa.Emboss(alpha=0.75, strength=1)
observed = aug.augment_image(self.base_img)
expected = self._compute_embossed_base_img(
self.base_img, alpha=0.75, strength=1)
assert self._allclose(observed, expected)
示例7: test_alpha_stochastic_parameter_strength_1
# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Emboss [as 别名]
def test_alpha_stochastic_parameter_strength_1(self):
aug = iaa.Emboss(alpha=iap.Choice([0.5, 1.0]), strength=1)
observed = aug.augment_image(self.base_img)
expected1 = self._compute_embossed_base_img(
self.base_img, alpha=0.5, strength=1)
expected2 = self._compute_embossed_base_img(
self.base_img, alpha=1.0, strength=1)
assert (
self._allclose(observed, expected1)
or self._allclose(observed, expected2)
)
示例8: test_alpha_1_strength_2
# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Emboss [as 别名]
def test_alpha_1_strength_2(self):
aug = iaa.Emboss(alpha=1.0, strength=2)
observed = aug.augment_image(self.base_img)
expected = self._compute_embossed_base_img(
self.base_img, alpha=1.0, strength=2)
assert self._allclose(observed, expected)
示例9: test_alpha_1_strength_3
# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Emboss [as 别名]
def test_alpha_1_strength_3(self):
aug = iaa.Emboss(alpha=1.0, strength=3)
observed = aug.augment_image(self.base_img)
expected = self._compute_embossed_base_img(
self.base_img, alpha=1.0, strength=3)
assert self._allclose(observed, expected)
示例10: test_alpha_1_strength_6
# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Emboss [as 别名]
def test_alpha_1_strength_6(self):
aug = iaa.Emboss(alpha=1.0, strength=6)
observed = aug.augment_image(self.base_img)
expected = self._compute_embossed_base_img(
self.base_img, alpha=1.0, strength=6)
assert self._allclose(observed, expected)
示例11: test_alpha_1_strength_stochastic_parameter
# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Emboss [as 别名]
def test_alpha_1_strength_stochastic_parameter(self):
aug = iaa.Emboss(alpha=1.0, strength=iap.Choice([1.0, 2.5]))
observed = aug.augment_image(self.base_img)
expected1 = self._compute_embossed_base_img(
self.base_img, alpha=1.0, strength=1.0)
expected2 = self._compute_embossed_base_img(
self.base_img, alpha=1.0, strength=2.5)
assert (
self._allclose(observed, expected1)
or self._allclose(observed, expected2)
)
示例12: test_failure_on_invalid_datatype_for_strength
# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Emboss [as 别名]
def test_failure_on_invalid_datatype_for_strength(self):
# don't use assertRaisesRegex, because it doesnt exist in 2.7
got_exception = False
try:
_ = iaa.Emboss(alpha=1.0, strength="test")
except Exception as exc:
assert "Expected " in str(exc)
got_exception = True
assert got_exception
示例13: __init__
# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Emboss [as 别名]
def __init__(self, alpha=(0.2, 0.5), strength=(0.2, 0.7), prob=0.5):
super().__init__(prob)
self.processor = iaa.Emboss(alpha, strength)
示例14: processor
# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Emboss [as 别名]
def processor(self):
return iaa.Emboss(self.alpha, self.strength)
示例15: _create_augment_pipeline
# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Emboss [as 别名]
def _create_augment_pipeline():
from imgaug import augmenters as iaa
### augmentors by https://github.com/aleju/imgaug
sometimes = lambda aug: iaa.Sometimes(0.5, aug)
# Define our sequence of augmentation steps that will be applied to every image
# All augmenters with per_channel=0.5 will sample one value _per image_
# in 50% of all cases. In all other cases they will sample new values
# _per channel_.
aug_pipe = iaa.Sequential(
[
# apply the following augmenters to most images
#iaa.Fliplr(0.5), # horizontally flip 50% of all images
#iaa.Flipud(0.2), # vertically flip 20% of all images
#sometimes(iaa.Crop(percent=(0, 0.1))), # crop images by 0-10% of their height/width
sometimes(iaa.Affine(
#scale={"x": (0.8, 1.2), "y": (0.8, 1.2)}, # scale images to 80-120% of their size, individually per axis
#translate_percent={"x": (-0.2, 0.2), "y": (-0.2, 0.2)}, # translate by -20 to +20 percent (per axis)
#rotate=(-5, 5), # rotate by -45 to +45 degrees
#shear=(-5, 5), # shear by -16 to +16 degrees
#order=[0, 1], # use nearest neighbour or bilinear interpolation (fast)
#cval=(0, 255), # if mode is constant, use a cval between 0 and 255
#mode=ia.ALL # use any of scikit-image's warping modes (see 2nd image from the top for examples)
)),
# execute 0 to 5 of the following (less important) augmenters per image
# don't execute all of them, as that would often be way too strong
iaa.SomeOf((0, 5),
[
#sometimes(iaa.Superpixels(p_replace=(0, 1.0), n_segments=(20, 200))), # convert images into their superpixel representation
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.Sharpen(alpha=(0, 1.0), lightness=(0.75, 1.5)), # sharpen images
#iaa.Emboss(alpha=(0, 1.0), strength=(0, 2.0)), # emboss images
# search either for all edges or for directed edges
#sometimes(iaa.OneOf([
# iaa.EdgeDetect(alpha=(0, 0.7)),
# iaa.DirectedEdgeDetect(alpha=(0, 0.7), direction=(0.0, 1.0)),
#])),
iaa.AdditiveGaussianNoise(loc=0, scale=(0.0, 0.05*255), per_channel=0.5), # add gaussian noise to images
iaa.OneOf([
iaa.Dropout((0.01, 0.1), per_channel=0.5), # randomly remove up to 10% of the pixels
#iaa.CoarseDropout((0.03, 0.15), size_percent=(0.02, 0.05), per_channel=0.2),
]),
#iaa.Invert(0.05, per_channel=True), # invert color channels
iaa.Add((-10, 10), per_channel=0.5), # change brightness of images (by -10 to 10 of original value)
iaa.Multiply((0.5, 1.5), per_channel=0.5), # change brightness of images (50-150% of original value)
iaa.ContrastNormalization((0.5, 2.0), per_channel=0.5), # improve or worsen the contrast
#iaa.Grayscale(alpha=(0.0, 1.0)),
#sometimes(iaa.ElasticTransformation(alpha=(0.5, 3.5), sigma=0.25)), # move pixels locally around (with random strengths)
#sometimes(iaa.PiecewiseAffine(scale=(0.01, 0.05))) # sometimes move parts of the image around
],
random_order=True
)
],
random_order=True
)
return aug_pipe