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

Function demo_densecrf2

examples/demo_densecrf.py:80–105  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

78 plt.show()
79
80def demo_densecrf2():
81 I = Image.open('../dependency/densecrf/examples/im3.ppm')
82 Iq = np.asarray(I, np.uint8)
83
84 # load initial labels, and convert it into an array 'prob' with shape [H, W, C]
85 # where C is the number of labels
86 # prob[h, w, c] means the probability of pixel at (h, w) belonging to class c.
87 L = Image.open('../dependency/densecrf/examples/anno3.ppm')
88 Lq = np.asarray(L, np.float32)
89 color_list = [[0, 128, 0], [192, 128, 0], [64, 64, 0]]
90 prob = convert_label_to_probability_map(Lq, color_list)
91
92 w1 = 10.0 # weight of bilateral term
93 alpha = 80 # spatial std
94 beta = 13 # rgb std
95 w2 = 3.0 # weight of spatial term
96 gamma = 3 # spatial std
97 it = 5.0 # iteration
98 param = (w1, alpha, beta, w2, gamma, it)
99 lab = densecrf(Iq, prob, param)
100 lab = colorize_label_map(lab, color_list)
101 lab = Image.fromarray(lab)
102 plt.subplot(1,3,1); plt.axis('off'); plt.imshow(I); plt.title('input image')
103 plt.subplot(1,3,2); plt.axis('off'); plt.imshow(L); plt.title('initial label')
104 plt.subplot(1,3,3); plt.axis('off'); plt.imshow(lab); plt.title('after dense CRF')
105 plt.show()
106
107if __name__ == "__main__":
108 print("example list")

Callers 1

demo_densecrf.pyFile · 0.85

Calls 3

densecrfFunction · 0.85
colorize_label_mapFunction · 0.85

Tested by

no test coverage detected