def parse_struc(img):
nbs = neighbors(img.shape)
acc = np.cumprod((1,)+img.shape[::-1][:-1])[::-1]
img = img.ravel()
pts = np.array(np.where(img==2))[0]
buf = np.zeros(131072, dtype=np.int64)
num = 10
nodes = []
for p in pts:
if img[p] == 2:
nds = fill(img, p, num, nbs, acc, buf)
num += 1
nodes.append(nds)
edges = []
for p in pts:
for dp in nbs:
if img[p+dp]==1:
edge = trace(img, p+dp, nbs, acc, buf)
edges.append(edge)
return nodes, edges
# use nodes and edges build a networkx graph
评论列表
文章目录