def normalize_contrast(x):
"""Normalize contrast of an image: forces values to be stricly in [0, 1]
:param x: image tensor
:return:
"""
idx = tf.range(1, tf.rank(x))
min = tf.reduce_min(x, idx, keep_dims=True)
max = tf.reduce_max(x, idx, keep_dims=True)
return (x - min) / (max - min + 1e-5)
评论列表
文章目录