def activate_boolean_map(bool_map):
"""
Performs activation on a single boolean map.
"""
# use the boolean map as a mask for flood filling
activation = np.array(bool_map, dtype=np.uint8)
mask_shape = (bool_map.shape[0] + 2, bool_map.shape[1] + 2)
ffill_mask = np.zeros(mask_shape, dtype=np.uint8)
# top and bottom rows
for i in range(0, activation.shape[0]):
for j in [0, activation.shape[1] - 1]:
if activation[i,j]:
cv2.floodFill(activation, ffill_mask, (j, i), 0)
# left and right columns
for i in [0, activation.shape[0] - 1]:
for j in range(0, activation.shape[1]):
if activation[i,j]:
cv2.floodFill(activation, ffill_mask, (j, i), 0)
return activation
评论列表
文章目录