maxflow for 2D image segmentation. Only binary segmentation is supported. input parameters: I : a numpy array of shape [H, W], or [H, W, C] where C should be 3. type of I should be np.float32 P : a probability map of shape [H, W, L], where L==2 is the nu
(I, P, param)
| 6 | import matplotlib.pyplot as plt |
| 7 | |
| 8 | def maxflow2d(I, P, param): |
| 9 | """ |
| 10 | maxflow for 2D image segmentation. Only binary segmentation is supported. |
| 11 | input parameters: |
| 12 | I : a numpy array of shape [H, W], or [H, W, C] where C should be 3. |
| 13 | type of I should be np.float32 |
| 14 | P : a probability map of shape [H, W, L], where L==2 is the number of classes |
| 15 | type of P should be np.float32 |
| 16 | param: a tuple giving parameters of CRF (lambda, sigma), where |
| 17 | lambda : weight of smooth term, e.g. 20.0 |
| 18 | sigma : std intensity value, e.g., 10 |
| 19 | |
| 20 | output parameters: |
| 21 | lab : a numpy array of shape [H, W], where pixel values represent class indices. |
| 22 | """ |
| 23 | lab = maxflow.maxflow2d(I, P, param) |
| 24 | return lab |
| 25 | |
| 26 | def interactive_maxflow2d(I, P, S, param): |
| 27 | """ |