forked from aleju/imgaug
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_voronoi.py
36 lines (26 loc) · 1.05 KB
/
check_voronoi.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
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((256, 256))
reggrid_sampler = iaa.DropoutPointsSampler(
iaa.RegularGridPointsSampler(n_rows=50, n_cols=50),
0.5
)
uniform_sampler = iaa.UniformPointsSampler(50*50)
for p_replace in [1.0, 0.5, 0.1, 0.0]:
augs = [
iaa.Voronoi(points_sampler=reggrid_sampler, p_replace=p_replace,
max_size=128),
iaa.Voronoi(points_sampler=uniform_sampler, p_replace=p_replace,
max_size=128),
iaa.UniformVoronoi(50*50, p_replace=p_replace, max_size=128),
iaa.RegularGridVoronoi(50, 50, p_drop_points=0.4,
p_replace=p_replace, max_size=128),
iaa.RelativeRegularGridVoronoi(p_replace=p_replace, max_size=128)
]
images = [aug(image=image) for aug in augs]
ia.imshow(np.hstack(images))
if __name__ == "__main__":
main()