def _neighbors_from_list_with_mask(self, labels, min_contact_area=None, real_area=True):
if (not self._neighbors is None) and (sum([i in self._neighbors.keys() for i in labels])==len(labels)):
result = dict([(i,self._neighbors[i]) for i in labels])
if min_contact_area is None:
return result
else:
return self._filter_with_area(result, min_contact_area, real_area)
edges = {}
for label in labels:
try:
slices = self.boundingbox(label)
ex_slices = dilation(slices)
mask_img = self.image[ex_slices]
except:
mask_img = self.image
neigh = list(contact_surface(mask_img,label))
if min_contact_area is not None:
neigh = self._neighbors_filtering_by_contact_area(label, neigh, min_contact_area, real_area)
edges[label] = neigh
return edges
spatial_image_analysis.py 文件源码
python
阅读 25
收藏 0
点赞 0
评论 0
评论列表
文章目录