def mask(self, size = (151, 151)):
"""Returns a binary mask for the worm shape
Arguments:
size (tuple ro array): size of the mask
Returns:
array: mask of worm shape
"""
mask = np.zeros(tuple(size));
left, right = self.shape();
for i in range(self.npoints-1):
poly = np.array([left[i,:], right[i,:], right[i+1,:], left[i+1,:]], dtype = np.int32)
cv2.fillPoly(mask, [poly], 1);
return np.asarray(mask, dtype = bool)
评论列表
文章目录