MCPcopy Create free account
hub / github.com/HiLab-git/WORD / __find_start

Method __find_start

scribbles_generator.py:121–141  ·  view source on GitHub ↗
(self, lab)

Source from the content-addressed store, hash-verified

119 0, -1], 4: [0, 0], 5: [0, 1], 6: [1, -1], 7: [1, 0], 8: [1, 1]}
120
121 def __find_start(self, lab):
122 y, x = lab.shape
123 idxes = np.asarray(np.nonzero(lab))
124 for i in range(idxes.shape[1]):
125 pt = tuple([idxes[0, i], idxes[1, i]])
126 assert lab[pt] == 1
127 directions = []
128 for d in range(9):
129 if d == 4:
130 continue
131 if self.__detect_pt_bifur_state(lab, pt, d):
132 directions.append(d)
133 if len(directions) == 1:
134 start = pt
135 self.start = start
136 self.output[start] = 1
137 return start
138 start = tuple([idxes[0, 0], idxes[1, 0]])
139 self.output[start] = 1
140 self.start = start
141 return start
142
143 def __detect_pt_bifur_state(self, lab, pt, direction):
144

Callers 1

__call__Method · 0.95

Calls 1

Tested by

no test coverage detected