(image, gamma=1, gain=1)
Performs Gamma Correction on the input image.

    Also known as Power Law Transform. This function transforms the
    input image pixelwise according to the equation Out = In**gamma
    after scaling each pixel to the range 0 to 1.

  Args:
    image : A Tensor.
    gamma : A scalar. Non negative real number.
    gain  : A scalar. The constant multiplier.

  Returns:
    A Tensor. Gamma corrected output image.

  Raises:
    ValueError: If gamma is negative.

  Notes:
    For gamma greater than 1, the histogram will shift towards left and
    the output image will be darker than the input image.
    For gamma less than 1, the histogram will shift towards right and
    the output image will be brighter than the input image.

  References:
    [1] http://en.wikipedia.org/wiki/Gamma_correction
Performs Gamma Correction on the input image.
Performs Gamma Correction on the input image .
def adjust_gamma(image, gamma=1, gain=1):
  """Performs Gamma Correction on the input image.

    Also known as Power Law Transform. This function transforms the
    input image pixelwise according to the equation Out = In**gamma
    after scaling each pixel to the range 0 to 1.

  Args:
    image : A Tensor.
    gamma : A scalar. Non negative real number.
    gain  : A scalar. The constant multiplier.

  Returns:
    A Tensor. Gamma corrected output image.

  Raises:
    ValueError: If gamma is negative.

  Notes:
    For gamma greater than 1, the histogram will shift towards left and
    the output image will be darker than the input image.
    For gamma less than 1, the histogram will shift towards right and
    the output image will be brighter than the input image.

  References:
    [1] http://en.wikipedia.org/wiki/Gamma_correction
  """

  with ops.op_scope([image, gamma, gain], None, 'adjust_gamma'):
    # Convert pixel value to DT_FLOAT for computing adjusted image
    img = ops.convert_to_tensor(image, name='img', dtype=dtypes.float32)
    # Keep image dtype for computing the scale of corresponding dtype
    image = ops.convert_to_tensor(image, name='image')

    if gamma < 0:
      raise ValueError('Gamma should be a non-negative real number')
    # scale = max(dtype) - min(dtype)
    scale = constant_op.constant(image.dtype.limits[1] - image.dtype.limits[0],
                                 dtype=dtypes.float32)
    # According to the definition of gamma correction
    adjusted_img = (img / scale) ** gamma * scale * gain

    return adjusted_img
def adjust_gamma ( image , gamma = 1 , gain = 1 ) : with ops . op_scope ( [ image , gamma , gain ] , None , 'adjust_gamma' ) : # Convert pixel value to DT_FLOAT for computing adjusted image img = ops . convert_to_tensor ( image , name = 'img' , dtype = dtypes . float32 ) # Keep image dtype for computing the scale of corresponding dtype image = ops . convert_to_tensor ( image , name = 'image' ) if gamma < 0 : raise ValueError ( 'Gamma should be a non-negative real number' ) # scale = max(dtype) - min(dtype) scale = constant_op . constant ( image . dtype . limits [ 1 ] - image . dtype . limits [ 0 ] , dtype = dtypes . float32 ) # According to the definition of gamma correction adjusted_img = ( img / scale ) ** gamma * scale * gain return adjusted_img