MCPcopy Create free account
hub / github.com/HiLab-git/SimpleCRF / convert_label_to_probability_map

Function convert_label_to_probability_map

examples/demo_densecrf.py:26–42  ·  view source on GitHub ↗
(label, color_list)

Source from the content-addressed store, hash-verified

24 return out
25
26def 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
44def colorize_label_map(label, color_list):
45 [H, W] = label.shape

Callers 1

demo_densecrf2Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected