MCPcopy Create free account
hub / github.com/HiLab-git/SimpleCRF / demo_interactive_maxflow

Function demo_interactive_maxflow

examples/demo_maxflow.py:104–127  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

102 plt.show()
103
104def demo_interactive_maxflow():
105 I = Image.open('../data/brain.png')
106 # Iq = np.asarray(I.convert('L'), np.float32)
107 Iq = np.asarray(I, np.float32)
108 P = np.asarray(Image.open('../data/brain_mask.png').convert('L'), np.float32) / 255
109
110 fP = 0.5 + (P - 0.5) * 0.8
111 bP = 1.0 - fP
112 Prob = np.asarray([bP, fP])
113 Prob = np.transpose(Prob, [1, 2, 0])
114
115 S = np.asarray(Image.open('../data/brain_scrb.png').convert('L'))
116 Seed = np.asarray([S == 255, S == 170], np.uint8)
117 Seed = np.transpose(Seed, [1, 2, 0])
118
119 lamda = 30.0
120 sigma = 8.0
121 param = (lamda, sigma)
122 lab = interactive_maxflow2d(Iq, Prob, Seed, param)
123
124 plt.subplot(1,3,1); plt.axis('off'); plt.imshow(I); plt.title('input image')
125 plt.subplot(1,3,2); plt.axis('off'); plt.imshow(fP); plt.title('initial \n segmentation')
126 plt.subplot(1,3,3); plt.axis('off'); plt.imshow(lab); plt.title('CRF result')
127 plt.show()
128
129def demo_maxflow3d():
130 img_name = "../data/2013_12_1_img.nii.gz"

Callers 1

demo_maxflow.pyFile · 0.85

Calls 2

interactive_maxflow2dFunction · 0.85
transposeMethod · 0.45

Tested by

no test coverage detected