def boundaries(regions, thin=False):
"""
Extracts region boundaries from a labelled image.
Args:
regions: numpy (H, W) array
Regions extracted from `image`
thin: bool
Whether to skeletonize or not the boundaries.
Return:
result: numpy (H, W) array
Region boundaries as a binary mask.
"""
# +1 to ignore superpixel 0 treated as background
result = find_boundaries(regions+1)
if thin:
result = skeletonize(result)
return result
评论列表
文章目录