maxflow for 3D interactive image segmentation. Only binary segmentation is supported. input parameters: I : a numpy array of shape [D, H, W], or [D, H, W, C] where C should be 3. type of I should be np.float32 P : a probability map of shape [D, H, W, L],
(I, P, S, param)
| 62 | return lab |
| 63 | |
| 64 | def interactive_maxflow3d(I, P, S, param): |
| 65 | """ |
| 66 | maxflow for 3D interactive image segmentation. Only binary segmentation is supported. |
| 67 | input parameters: |
| 68 | I : a numpy array of shape [D, H, W], or [D, H, W, C] where C should be 3. |
| 69 | type of I should be np.float32 |
| 70 | P : a probability map of shape [D, H, W, L], where L==2 is the number of classes |
| 71 | type of P should be np.float32 |
| 72 | S : a numpy array showing user interactions, shape should be [D, H, W, L], where L == 2 |
| 73 | type of S should be np.uint8 |
| 74 | param: a tuple giving parameters of CRF (lambda, sigma), where |
| 75 | lambda : weight of smooth term, e.g. 20.0 |
| 76 | sigma : std intensity value, e.g., 10 |
| 77 | |
| 78 | output parameters: |
| 79 | lab : a numpy array of shape [D, H, W], where pixel values represent class indices. |
| 80 | """ |
| 81 | lab = maxflow.interactive_maxflow3d(I, P, S, param) |
| 82 | return lab |
| 83 | |
| 84 | def demo_maxflow(): |
| 85 | I = Image.open('../data/brain.png') |
no outgoing calls