-
Notifications
You must be signed in to change notification settings - Fork 12
/
example.py
51 lines (41 loc) · 1.28 KB
/
example.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
# %%
## GENERATE SOME RANDOM IMAGES
from randimage import get_random_image, show_img_list
#%reload_ext autoreload
#%autoreload 2
#%%
SHAPE = (4, 8)
SIZE = SHAPE[0]*SHAPE[1]
imgs = []
img_size = (128,128)
for i in range(SIZE):
img = get_random_image(img_size)
imgs.append(img)
figure = show_img_list(imgs, SHAPE)
#%%
# SAVE THE FIGURE
# figure = show_img_list(imgs, SHAPE, figsize=(200,100))
# figure.savefig('randimage.jpg',dpi=5)
#%%
# MANUALLY DEFINE MASK AND PATH MODULES
from randimage import GaussianBlobMask, NormalMask, SaltPepperMask, EPWTPath, ProbabilisticPath, ColoredPath, show_array
img_size = (280,280)
# mask = SaltPepperMask(img_size).get_mask()
# mask = NormalMask(img_size).get_mask()
mask = GaussianBlobMask(img_size).get_mask(5)
# show_array(mask, cmap='gray')
# mask = GaussianBlobMask().get_mask()
epwtpath = EPWTPath(mask).get_path()
ppath = ProbabilisticPath(mask).get_path()
cmap = 'Spectral'
epwtimg = ColoredPath(epwtpath, mask.shape).get_colored_path(cmap)
pimg = ColoredPath(ppath, mask.shape).get_colored_path(cmap)
show_array(mask)
show_array(epwtimg)
show_array(pimg)
#%%
# SAVE THE IMAGES
# import matplotlib
# matplotlib.image.imsave("mask.png", mask, cmap='gray')
# matplotlib.image.imsave("epwt.png", epwtimg)
# matplotlib.image.imsave("prob.png", pimg)