| 24 | return out |
| 25 | |
| 26 | def convert_label_to_probability_map(label, color_list): |
| 27 | [H, W, _] = label.shape |
| 28 | C = len(color_list) |
| 29 | prob = np.zeros([H, W, len(color_list)], np.float32) |
| 30 | for h in range(H): |
| 31 | for w in range(W): |
| 32 | ca = label[h, w, :] |
| 33 | if sum(ca) == 0: |
| 34 | for c in range(C): |
| 35 | prob[h, w, c] = 1.0 / C |
| 36 | else: |
| 37 | for c in range(C): |
| 38 | cb = color_list[c] |
| 39 | if(ca[0]==cb[0] and ca[1]==cb[1] and ca[2]==cb[2]): |
| 40 | prob[h, w, c] = 1.0 |
| 41 | break |
| 42 | return prob |
| 43 | |
| 44 | def colorize_label_map(label, color_list): |
| 45 | [H, W] = label.shape |