/
testbgrsp.py
112 lines (89 loc) · 2.39 KB
/
testbgrsp.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
from filtering.anisotropic import *
from rivuletpy.utils.io import *
import matplotlib.pyplot as plt
from scipy import io as sio
try:
from skimage import filters
except ImportError:
from skimage import filter as filters
from scipy.ndimage.filters import gaussian_filter
mat = sio.loadmat('tests/data/very-small-oof.mat', )
img = mat['img']
ostu_img = 0.
radii = np.arange(0.2, 2, 0.5)
rho = 0.5
oof_matlab = mat['oof']
ostu_matlaboof = filters.threshold_otsu(oof_matlab)
rps, _ = response(img.astype('float'), rsptype='bg', radii=radii, rho=rho)
thr = 1
from scipy import ndimage as ndi
from skimage import feature
canny = feature.canny(rps, sigma=3)
smoothed_rps = gaussian_filter(rps, 0.5)
# ostu_smooth = filters.threshold_otsu(smoothed_rps)
ostu_smooth = 1
plotidx = 1
plt.subplot(4, 4, plotidx)
plt.imshow(rps.max(axis=0))
plt.title('OOF Python MEM_SAVE YZ')
plotidx += 1
plt.subplot(4, 4, plotidx)
plt.imshow(rps.max(axis=1))
plt.title('OOF Python MEM_SAVE XZ')
plotidx += 1
plt.subplot(4, 4, plotidx)
plt.imshow(rps.max(axis=2))
plt.title('OOF Python MEM_SAVE XY')
plotidx += 1
plt.subplot(4, 4, plotidx)
plt.imshow((rps > thr).max(axis=2))
plt.title('OOF Python MEM_SAVE Otsu XY')
plotidx += 1
plt.subplot(4, 4, plotidx)
plt.imshow(smoothed_rps.max(axis=0))
plt.title('Smooth YZ')
plotidx += 1
plt.subplot(4, 4, plotidx)
plt.imshow(smoothed_rps.max(axis=1))
plt.title('Smooth XZ')
plotidx += 1
plt.subplot(4, 4, plotidx)
plt.imshow(smoothed_rps.max(axis=2))
plt.title('Smooth XY')
plotidx += 1
plt.subplot(4, 4, plotidx)
plt.imshow((smoothed_rps > ostu_smooth).max(axis=2))
plt.title('Smooth XY')
plotidx +=1
plt.subplot(4, 4, plotidx)
plt.imshow(canny.max(axis=0))
plt.title('OOF Matlab YZ')
plotidx += 1
plt.subplot(4, 4, plotidx)
plt.imshow(canny.max(axis=1))
plt.title('OOF Matlab XZ')
plotidx += 1
plt.subplot(4, 4, plotidx)
plt.imshow(canny.max(axis=2))
plt.title('OOF Matlab XY')
plotidx += 1
plt.subplot(4, 4, plotidx)
plt.imshow((canny > ostu_matlaboof).max(axis=2))
plt.title('OOF Matlab Otsu XY')
plotidx += 1
plt.subplot(4, 4, plotidx)
plt.imshow(img.max(axis=0))
plt.title('Original YZ')
plotidx += 1
plt.subplot(4, 4, plotidx)
plt.imshow(img.max(axis=1))
plt.title('Original XZ')
plotidx += 1
plt.subplot(4, 4, plotidx)
plt.imshow(img.max(axis=2))
plt.title('Original XY')
plotidx += 1
plt.subplot(4, 4, plotidx)
plt.imshow((img > ostu_img).max(axis=2))
plt.title('Original Otsu XY')
plt.show()