Table of Contents
Shortcuts

# adjust_gamma

torchvision.transforms.functional.adjust_gamma(img: Tensor, gamma: float, gain: float = 1) → Tensor

  Perform gamma correction on an image.

  Also known as Power Law Transform. Intensities in RGB mode are adjusted based on the following equation:

  \[I_{\text{out}} = 255 \times \text{gain} \times \left(\frac{I_{\text{in}}}{255}\right)^{\gamma}\]

  See Gamma Correction for more details.

  Parameters:

    - img (PIL Image or Tensor) – PIL Image to be adjusted. If img is torch Tensor, it is expected to be in […, 1 or 3, H, W] format, where … means it can have an arbitrary number of leading dimensions. If img is PIL Image, modes with transparency (alpha channel) are not supported.

    - gamma (float) – Non negative real number, same as \(\gamma\) in the equation. gamma larger than 1 make the shadows darker, while gamma smaller than 1 make dark regions lighter.

    - gain (float) – The constant multiplier.

  Returns:

    Gamma correction adjusted image.

  Return type:

    PIL Image or Tensor

## Docs

Access comprehensive developer documentation for PyTorch

View Docs

## Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

## Resources

Find development resources and get your questions answered

View Resources

To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: Cookies Policy.