()
| 82 | return lab |
| 83 | |
| 84 | def 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 | |
| 104 | def demo_interactive_maxflow(): |
| 105 | I = Image.open('../data/brain.png') |
no test coverage detected