Skip to content

Enhance Image Using Auto Gamma Correction

SUMMARY

Enhance Image Using Auto Gamma Correction automatically adjusts image brightness using an adaptively estimated gamma value.

The gamma value is computed from the image's own luminance statistics and applied as a non-linear brightness transform to normalize overall exposure — there is no manual gamma parameter to set. It corrects global brightness only; it does not address uneven illumination across different regions of the same image.

Use this Skill when you want to normalize brightness under dark or unknown lighting conditions without hand-tuning a gamma value.

The Skill

python
from telekinesis import pupil

corrected_image = pupil.enhance_image_using_auto_gamma_correction(
    image=image
)
API Reference
Full parameter and return type documentation for enhance_image_using_auto_gamma_correction.
View Reference →

Example

Input Image

Input image

Original image captured under dark lighting

Enhanced Image

Output image

Gamma-corrected image with normalized brightness

The Code

python
"""Demonstrates enhance_image_using_auto_gamma_correction operation."""

from loguru import logger
import rerun as rr

from telekinesis import pupil, datatypes


def enhance_image_using_auto_gamma_correction_example():
    """Applies enhance_image_using_auto_gamma_correction operation."""
    # ===================== Load Image ==========================================
    image_url = "https://assets.telekinesis.ai/examples/v1/images/screws_in_dark_lighting.jpg"
    image = datatypes.Image.from_url(image_url)

    # ===================== Run Skill ==========================================
    filtered_image = pupil.enhance_image_using_auto_gamma_correction(
        image=image,
    )

    # ===================== Log ================================================
    logger.success(f"Applied enhance_image_using_auto_gamma_correction on {image}")
    logger.success(f"Result: {filtered_image}")

    # ===================== Visualization  (Optional) ======================
    rr.init("enhance_image_using_auto_gamma_correction_example", spawn=True)
    datatypes.visualize(image, entity_path="1-Original")
    datatypes.visualize(filtered_image, entity_path="2-Enhanced")

if __name__ == "__main__":
    enhance_image_using_auto_gamma_correction_example()

Runnable examples are available in the Telekinesis examples repository.

Follow the README in that repository to set up the environment, run this specific example with:

bash
cd telekinesis-examples
python examples/image_processing/enhance_image_using_auto_gamma_correction.py

Parameter Configuration

KeyTypeDefaultDescription
imagedatatypes.Image | np.ndarrayrequiredThe input image to process, shape (H, W) or (H, W, C)

Returns

TypeDescription
datatypes.ImageSame shape as image, with brightness gamma-corrected using an automatically estimated gamma value.

Raises

ExceptionCondition
TypeErrorimage has an invalid type
ConfigurationErrorThe TELEKINESIS_API_KEY environment variable is not set
SerializationErrorThe request input failed to serialize, or the response failed to deserialize
RequestTimeoutErrorThe request to the Pupil service timed out
TransportErrorA network failure occurred before a response was received
ClientErrorThe Pupil service rejected the request due to invalid input, invalid data, or another unexpected 4xx response
AuthenticationErrorThe API key was rejected as invalid or expired
AuthenticationServiceErrorThe authentication service was unavailable
ServerErrorThe Pupil service returned a 5xx or otherwise unexpected error response

How to Tune the Parameters

enhance_image_using_auto_gamma_correction has no tunable parameters — the gamma value is derived automatically from the image's luminance statistics rather than passed in.

TIP

Best practice: Use this Skill for a quick, hands-off global brightness fix. If different regions of the same image are under- and over-exposed simultaneously, a single gamma value can't correct both — use enhance_image_using_clahe instead.

Where to Use the Skill

Common pipelines include:

  • Exposure normalization – Normalize brightness for images captured under varying or unknown lighting before downstream processing
  • Preprocessing for detection/segmentation – Improve the robustness of skills that are sensitive to low contrast or dark images
  • Dataset normalization – Reduce brightness-related variance across a batch of images captured under inconsistent conditions

Alternative Skills

Skillvs. Enhance Image Using Auto Gamma Correction
enhance_image_using_claheEnhances local contrast per-region instead of applying a single global brightness transform. Use when illumination is uneven across the image.
enhance_image_using_white_balanceCorrects color temperature/color casts rather than brightness. Use when the issue is color, not exposure.
normalize_image_intensityRescales intensity values to a target range via a linear/explicit method instead of an estimated gamma curve.

When Not to Use the Skill

Do not use Enhance Image Using Auto Gamma Correction when:

  • Photometric accuracy is required (it alters intensity values heuristically, not based on a calibrated model)
  • A specific, known gamma value is required (this Skill only supports automatic estimation; there is no manual gamma parameter)
  • Illumination is uneven across the image (a single global gamma cannot fix both under- and over-exposed regions — use enhance_image_using_clahe instead)
  • The image is already well-exposed (applying gamma correction risks overcorrection)