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));
xyl, xyr, xym = self.sides();
for i in range(self.npoints-1):
poly = np.array([xyl[i,:], xyr[i,:], xyr[i+1,:], xyl[i+1,:]], dtype = np.int32)
cv2.fillPoly(mask, [poly], 1);
return np.asarray(mask, dtype = bool)
评论列表
文章目录