def getForegroundMask(self):
'''
@return: A mask image indicating which pixels are considered foreground.
Depending on whether soft-thresholding is used, this may be a binary image
with values of [0 or 255], or image of weights [0.0-255.0], which will
have to be divided by 255 to get weights [0.0-1.0].
@note: One may wish to perform additional morphological operations
on the foreground mask prior to use.
'''
diff = self._computeBGDiff()
if self._softThreshold:
mask = 1 - (math.e)**(-(1.0*diff)/self._threshold) #element-wise exp weighting
#mask = (diff > self._threshold)
else:
mask = (sp.absolute(diff) > self._threshold)
#mu = sp.mean(diff)
#sigma = sp.std(diff)
#mask = sp.absolute((diff-mu)/sigma) > self._threshold
return pv.Image(mask*255.0)
评论列表
文章目录