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

Function demo_densecrf1

examples/demo_densecrf.py:54–78  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

52 return out
53
54def demo_densecrf1():
55 I = Image.open('../data/brain.png')
56 Iq = np.asarray(I)
57
58 # load initial labels, and convert it into an array 'prob' with shape [H, W, C]
59 # where C is the number of labels
60 # prob[h, w, c] means the probability of pixel at (h, w) belonging to class c.
61 L = Image.open('../data/brain_mask.png')
62 Lq = np.asarray(L, np.float32) / 255
63 prob = Lq[:, :, :2]
64 prob[:, :, 0] = 1.0 - prob[:, :, 0]
65
66 w1 = 10.0 # weight of bilateral term
67 alpha = 80 # spatial std
68 beta = 13 # rgb std
69 w2 = 3.0 # weight of spatial term
70 gamma = 3 # spatial std
71 it = 5.0 # iteration
72 param = (w1, alpha, beta, w2, gamma, it)
73 lab = densecrf(Iq, prob, param)
74 lab = Image.fromarray(lab*255)
75 plt.subplot(1,3,1); plt.axis('off'); plt.imshow(I); plt.title('input image')
76 plt.subplot(1,3,2); plt.axis('off'); plt.imshow(L); plt.title('initial label')
77 plt.subplot(1,3,3); plt.axis('off'); plt.imshow(lab); plt.title('after dense CRF')
78 plt.show()
79
80def demo_densecrf2():
81 I = Image.open('../dependency/densecrf/examples/im3.ppm')

Callers 1

demo_densecrf.pyFile · 0.85

Calls 1

densecrfFunction · 0.85

Tested by

no test coverage detected