Missed TensorFlow Dev Summit? Check out the video playlist. Watch recordings


TensorFlow 1 version View source on GitHub

Performs Gamma Correction.

    image, gamma=1, gain=1

on the input image.

Also known as Power Law Transform. This function converts the input images at first to float representation, then transforms them pixelwise according to the equation Out = gain * In**gamma, and then converts the back to the original data type.

Usage Example:

x = [[[1.0, 2.0, 3.0], 
      [4.0, 5.0, 6.0]], 
    [[7.0, 8.0, 9.0], 
      [10.0, 11.0, 12.0]]] 
tf.image.adjust_gamma(x, 0.2) 
<tf.Tensor: shape=(2, 2, 3), dtype=float32, numpy= 
array([[[1.       , 1.1486983, 1.2457309], 
        [1.319508 , 1.3797297, 1.4309691]], 
       [[1.4757731, 1.5157166, 1.5518456], 
        [1.5848932, 1.6153942, 1.6437519]]], dtype=float32)> 


  • image: RGB image or images to adjust.
  • gamma: A scalar or tensor. Non-negative real number.
  • gain: A scalar or tensor. The constant multiplier.


A Tensor. A Gamma-adjusted tensor of the same shape and type as image.


  • ValueError: If gamma is negative.


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.