()
| 102 | plt.show() |
| 103 | |
| 104 | def 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 | |
| 129 | def demo_maxflow3d(): |
| 130 | img_name = "../data/2013_12_1_img.nii.gz" |
no test coverage detected