def bloom(tensor, shape, alpha=.5):
"""
Bloom effect
:param Tensor tensor:
:param list[int] shape:
:param float alpha:
"""
height, width, channels = shape
blurred = tf.maximum(tensor * 2.0 - 1.0, 0.0)
blurred = _downsample(blurred, shape, [max(int(height * .01), 1), max(int(width * .01), 1), channels]) * 4.0
blurred = resample(blurred, shape)
blurred = offset(blurred, shape, x=int(shape[1] * -.05), y=int(shape[0] * -.05))
return blend(tensor, normalize(tensor + blurred), alpha)
评论列表
文章目录