input parameters: I : a numpy array of shape [H, W, C], where C should be 3. type of I should be np.uint8, and the values are in [0, 255] P : a probability map of shape [H, W, L], where L is the number of classes type of P should be np.float32
(I, P, param)
| 4 | import matplotlib.pyplot as plt |
| 5 | |
| 6 | def densecrf(I, P, param): |
| 7 | """ |
| 8 | input parameters: |
| 9 | I : a numpy array of shape [H, W, C], where C should be 3. |
| 10 | type of I should be np.uint8, and the values are in [0, 255] |
| 11 | P : a probability map of shape [H, W, L], where L is the number of classes |
| 12 | type of P should be np.float32 |
| 13 | param: a tuple giving parameters of CRF (w1, alpha, beta, w2, gamma, it), where |
| 14 | w1 : weight of bilateral term, e.g. 10.0 |
| 15 | alpha : spatial distance std, e.g., 80 |
| 16 | beta : rgb value std, e.g., 15 |
| 17 | w2 : weight of spatial term, e.g., 3.0 |
| 18 | gamma : spatial distance std for spatial term, e.g., 3 |
| 19 | it : iteration number, e.g., 5 |
| 20 | output parameters: |
| 21 | out : a numpy array of shape [H, W], where pixel values represent class indices. |
| 22 | """ |
| 23 | out = denseCRF.densecrf(I, P, param) |
| 24 | return out |
| 25 | |
| 26 | def convert_label_to_probability_map(label, color_list): |
| 27 | [H, W, _] = label.shape |
no outgoing calls
no test coverage detected