def adjust_brightness(images, delta, is_random=False, seed=None):
"""Adjust (randomly) the brightness of RGB or Grayscale images.
(A mirror to tf.image adjust_brightness, random_birightness)
This is a convenience method that converts an RGB image to float
representation, adjusts its brightness, and then converts it back to the
original data type. If several adjustments are chained it is advisable to
minimize the number of redundant conversions.
The value `delta` is added to all components of the tensor `image`. Both
`image` and `delta` are converted to `float` before adding (and `image` is
scaled appropriately if it is in fixed-point representation). For regular
images, `delta` should be in the range `[0,1)`, as it is added to the image in
floating point representation, where pixel values are in the `[0,1)` range.
If `is_random` is `True`, adjust brightness using a value randomly picked in the
interval `[-delta, delta)`.
Args:
images: A tensor.
delta: `float`. Amount to add to the pixel values.
is_random: `bool`, If True, adjust randomly.
seed: A Python integer. Used to create a random seed. See @{tf.set_random_seed}.
Returns:
A brightness-adjusted tensor of the same shape and type as `images`.
"""
if is_random:
return tf.image.random_brightness(images, max_delta=delta, seed=seed)
return tf.image.adjust_brightness(images, delta=delta)
评论列表
文章目录