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

Function demo_maxflow

examples/demo_maxflow.py:84–102  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

82 return lab
83
84def demo_maxflow():
85 I = Image.open('../data/brain.png')
86 Iq = np.asarray(I.convert('L'), np.float32)
87 # Iq = np.asarray(I, np.float32)
88 P = np.asarray(Image.open('../data/brain_mask.png').convert('L'), np.float32) / 255
89
90 fP = 0.5 + (P - 0.5) * 0.8
91 bP = 1.0 - fP
92 Prob = np.asarray([bP, fP])
93 Prob = np.transpose(Prob, [1, 2, 0])
94 lamda = 20.0
95 sigma = 10.0
96 param = (lamda, sigma)
97 lab = maxflow2d(Iq, Prob, param)
98
99 plt.subplot(1,3,1); plt.axis('off'); plt.imshow(I); plt.title('input image')
100 plt.subplot(1,3,2); plt.axis('off'); plt.imshow(fP); plt.title('initial \n segmentation')
101 plt.subplot(1,3,3); plt.axis('off'); plt.imshow(lab); plt.title('CRF result')
102 plt.show()
103
104def demo_interactive_maxflow():
105 I = Image.open('../data/brain.png')

Callers 1

demo_maxflow.pyFile · 0.85

Calls 2

maxflow2dFunction · 0.85
transposeMethod · 0.45

Tested by

no test coverage detected