-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy patherode_map_3d.py
More file actions
executable file
·64 lines (53 loc) · 1.59 KB
/
erode_map_3d.py
File metadata and controls
executable file
·64 lines (53 loc) · 1.59 KB
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
56
57
58
59
60
61
62
63
64
#!/usr/bin/python3
import numpy as np
import matplotlib.pyplot as plt
from skimage.morphology import ball
from quantimpy import minkowski as mk
from quantimpy import morphology as mp
from math import prod
image0 = np.zeros([64,64,64],dtype=bool)
image0[8:57,8:57,8:57] = ball(24,dtype=bool)
res0 = np.array([2.0, 2.0, 2.0])
ext0 = [0, image0.shape[0]*res0[0], 0, image0.shape[1]*res0[1]]
image1 = np.zeros([128,128,128],dtype=bool)
image1[16:113,16:113,16:113] = ball(48,dtype=bool)
image2 = np.zeros([256,256,256],dtype=bool)
image2[32:225,32:225,32:225] = ball(96,dtype=bool)
res2 = np.array([0.5, 0.5, 0.5])
ext2 = [0, image2.shape[0]*res2[0], 0, image2.shape[1]*res2[1]]
image3 = np.zeros([128,256,256],dtype=bool)
image3[16:113,32:225,32:225] = ball(96,dtype=bool)[0::2,:]
res3 = np.array([1.0, 0.5, 0.5])
ext3 = [0, image3.shape[0]*res3[0], 0, image3.shape[1]*res3[1]]
#plt.gray()
#plt.imshow(image0[:,:,32],extent=ext0)
#plt.show()
#
#plt.gray()
#plt.imshow(image1[:,:,64])
#plt.show()
#
#plt.gray()
#plt.imshow(image2[:,:,128],extent=ext2)
#plt.show()
#
#plt.gray()
#plt.imshow(image3[:,:,128],extent=ext3)
#plt.show()
erosion_map0 = mp.erode_map(image0,res0)
erosion_map1 = mp.erode_map(image1)
erosion_map2 = mp.erode_map(image2,res2)
erosion_map3 = mp.erode_map(image3,res3)
# These images should be the same (exept difference caused by resolution)
plt.gray()
plt.imshow(erosion_map0[:,:,32],extent=ext0)
plt.show()
plt.gray()
plt.imshow(erosion_map1[:,:,64])
plt.show()
plt.gray()
plt.imshow(erosion_map2[:,:,128],extent=ext2)
plt.show()
plt.gray()
plt.imshow(erosion_map3[:,:,128],extent=ext3)
plt.show()