MCPcopy Index your code
hub / github.com/HiLab-git/WORD / scrible_2d

Function scrible_2d

scribbles_generator.py:213–230  ·  view source on GitHub ↗
(label, iteration=[4, 10])

Source from the content-addressed store, hash-verified

211
212
213def scrible_2d(label, iteration=[4, 10]):
214 lab = label
215 skeleton_map = np.zeros_like(lab, dtype=np.int32)
216 for i in range(lab.shape[0]):
217 if np.sum(lab[i]) == 0:
218 continue
219 struct = ndimage.generate_binary_structure(2, 2)
220 if np.sum(lab[i]) > 900 and iteration != 0 and iteration != [0] and iteration != None:
221 iter_num = math.ceil(
222 iteration[0]+random.random() * (iteration[1]-iteration[0]))
223 slic = ndimage.morphology.binary_erosion(
224 lab[i], structure=struct, iterations=iter_num)
225 else:
226 slic = lab[i]
227 sk_slice = skeletonize(slic, method='lee')
228 sk_slice = np.asarray((sk_slice == 255), dtype=np.int32)
229 skeleton_map[i] = sk_slice
230 return skeleton_map
231
232
233def scribble4class(label, class_id, class_num, iteration=[4, 10], cut_branch=True):

Callers 1

scribble4classFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected