forked from aleju/imgaug
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_bilateral_blur.py
55 lines (44 loc) · 1.57 KB
/
check_bilateral_blur.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from __future__ import print_function, division
import imgaug as ia
from imgaug import augmenters as iaa
import numpy as np
from skimage import data
import cv2
TIME_PER_STEP = 5000
NB_AUGS_PER_IMAGE = 10
def main():
image = data.astronaut()
image = ia.imresize_single_image(image, (128, 128))
print("image shape:", image.shape)
print("Press any key or wait %d ms to proceed to the next image." % (TIME_PER_STEP,))
configs = [
(1, 75, 75),
(3, 75, 75),
(5, 75, 75),
(10, 75, 75),
(10, 25, 25),
(10, 250, 150),
(15, 75, 75),
(15, 150, 150),
(15, 250, 150),
(20, 75, 75),
(40, 150, 150),
((1, 5), 75, 75),
(5, (10, 250), 75),
(5, 75, (10, 250)),
(5, (10, 250), (10, 250)),
(10, (10, 250), (10, 250)),
]
cv2.namedWindow("aug", cv2.WINDOW_NORMAL)
cv2.resizeWindow("aug", 128*NB_AUGS_PER_IMAGE, 128)
for (d, sigma_color, sigma_space) in configs:
aug = iaa.BilateralBlur(d=d, sigma_color=sigma_color, sigma_space=sigma_space)
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 = "d=%s, sc=%s, ss=%s" % (str(d), str(sigma_color), str(sigma_space))
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)
if __name__ == "__main__":
main()