forked from aleju/imgaug
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_brightness.py
38 lines (29 loc) · 1.24 KB
/
check_brightness.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from __future__ import print_function, division
import numpy as np
import imgaug as ia
import imgaug.augmenters as iaa
def main():
image = ia.quokka_square(size=(100, 100))
for cspace in iaa.WithBrightnessChannels._VALID_COLORSPACES:
print(cspace, "add")
images_aug = []
for add in np.linspace(-200, 200, 64):
aug = iaa.MultiplyAndAddToBrightness(add=add, mul=1.0,
to_colorspace=cspace)
images_aug.append(aug(image=image))
ia.imshow(ia.draw_grid(images_aug))
for cspace in iaa.WithBrightnessChannels._VALID_COLORSPACES:
print(cspace, "mul")
images_aug = []
for mul in np.linspace(0.5, 1.5, 64):
aug = iaa.MultiplyAndAddToBrightness(add=0, mul=mul,
to_colorspace=cspace)
images_aug.append(aug(image=image))
ia.imshow(ia.draw_grid(images_aug))
for cspace in iaa.WithBrightnessChannels._VALID_COLORSPACES:
print(cspace, "defaults")
aug = iaa.MultiplyAndAddToBrightness(to_colorspace=cspace)
images_aug = aug(images=[image] * 64)
ia.imshow(ia.draw_grid(images_aug))
if __name__ == "__main__":
main()