MCPcopy Create free account
hub / github.com/AIRMEC/HECTOR / detect_foreground

Function detect_foreground

extract_features.py:235–251  ·  view source on GitHub ↗
(contours, hierarchy)

Source from the content-addressed store, hash-verified

233 return all_polygons
234
235def detect_foreground(contours, hierarchy):
236 hierarchy = np.squeeze(hierarchy, axis=(0,))[:, 2:]
237
238 # find foreground contours (parent == -1)
239 hierarchy_1 = np.flatnonzero(hierarchy[:, 1] == -1)
240 foreground_contours = [contours[cont_idx] for cont_idx in hierarchy_1]
241
242 all_holes = []
243 for cont_idx in hierarchy_1:
244 all_holes.append(np.flatnonzero(hierarchy[:, 1] == cont_idx))
245
246 hole_contours = []
247 for hole_ids in all_holes:
248 holes = [contours[idx] for idx in hole_ids]
249 hole_contours.append(holes)
250
251 return foreground_contours, hole_contours
252
253def construct_polygon(foreground_contours, hole_contours, min_area):
254 polys = []

Callers 1

create_tissue_maskFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected