def drop_shadow(self, alpha, theta, shift, size, op=0.80):
"""
alpha : alpha layer whose shadow need to be cast
theta : [0,2pi] -- the shadow direction
shift : shift in pixels of the shadow
size : size of the GaussianBlur filter
op : opacity of the shadow (multiplying factor)
@return : alpha of the shadow layer
(it is assumed that the color is black/white)
"""
if size%2==0:
size -= 1
size = max(1,size)
shadow = cv.GaussianBlur(alpha,(size,size),0)
[dx,dy] = shift * np.array([-np.sin(theta), np.cos(theta)])
shadow = op*sii.shift(shadow, shift=[dx,dy],mode='constant',cval=0)
return shadow.astype('uint8')
评论列表
文章目录