def __call__(self, roi_slice, num):
blob_labels = self.blob_labels[roi_slice]
# everthing not pertaining to blobs becomes 1
binary = (blob_labels >= 255).astype(np.uint8)
blob_mask = (blob_labels == num)
dist, voronoilabels = cv2.distanceTransformWithLabels(binary, cv2.DIST_L2, 3)
vl = set(voronoilabels[blob_mask])
if len(vl) != 1:
print 'WARNING: In MaskVoronoiLocal, more than one label pertains to the area of the blob.'
return np.ones(blob_labels.shape, np.bool)
vl = vl.pop()
# plt.imshow(binary)
# plt.colorbar()
# plt.show()
# plt.imshow(voronoilabels)
# plt.colorbar()
# plt.show()
return voronoilabels == vl
评论列表
文章目录