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

Function demo_maxflow3d

examples/demo_maxflow.py:129–152  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

127 plt.show()
128
129def demo_maxflow3d():
130 img_name = "../data/2013_12_1_img.nii.gz"
131 prob_name = "../data/2013_12_1_init.nii.gz"
132 save_name = "../data/seg_auto.nii.gz"
133 img_obj = sitk.ReadImage(img_name)
134 img_data = sitk.GetArrayFromImage(img_obj)
135 img_data = np.asarray(img_data, np.float32)
136 prob_obj = sitk.ReadImage(prob_name)
137 prob_data = sitk.GetArrayFromImage(prob_obj)
138 prob_data = np.asarray(prob_data, np.float32)
139
140 fP = 0.5 + (prob_data - 0.5) * 0.8
141 bP = 1.0 - fP
142 Prob = np.asarray([bP, fP])
143 Prob = np.transpose(Prob, [1, 2, 3, 0])
144
145 lamda = 10.0
146 sigma = 15.0
147 param = (lamda, sigma)
148 lab = maxflow3d(img_data, Prob, param)
149 lab_obj = sitk.GetImageFromArray(lab)
150 lab_obj.CopyInformation(img_obj)
151 sitk.WriteImage(lab_obj, save_name)
152 print('the segmentation has been saved to {0:}'.format(save_name))
153
154def test_interactive_max_flow3d():
155 img_name = "../data/2013_12_1_img.nii.gz"

Callers 1

demo_maxflow.pyFile · 0.85

Calls 3

maxflow3dFunction · 0.85
printFunction · 0.50
transposeMethod · 0.45

Tested by

no test coverage detected