DEV Community

Cover image for Chromatic Aberration Transform in Albumentations 1.4.2
Vladimir Iglovikov
Vladimir Iglovikov

Posted on

Chromatic Aberration Transform in Albumentations 1.4.2

Albumentations 1.4.2 adds the Chromatic Aberration transform. This feature simulates the common lens aberration effect, causing color fringes in images due to the lens's inability to focus all colors at the same convergence point.

Understanding Chromatic Aberration

Chromatic Aberration results from lens dispersion, where light of different wavelengths refracts at slightly varied angles.

Wiki

The Albumentations library introduces this as a visual effect rather than a precise optical simulation, offering two modes to mimic the appearance of chromatic aberration: green_purple and red_blue.

Enhancing Model Robustness

Applying the Chromatic Aberration transform can increase a model's robustness to real-world imaging conditions. It's particularly relevant for:

  • High-contrast scenes
  • Wide apertures photography
  • Telephoto lens usage
  • Digital zooming
  • Underwater and action photography

Code Example

Original image

Original image

transform = A.Compose([A.ChromaticAberration(mode="red_blue", 
primary_distortion_limit=0.5, 
secondary_distortion_limit=0.1, 
p=1)], p=1)

transformed = transform(image=img)["image"]
Enter fullscreen mode Exit fullscreen mode

Transformed

Or as a part of the more general pipeline.

transform = A.Compose([
    A.RandomCrop(height=300, width=200, p=1),
    A.HorizontalFlip(p=0.5),    
    A.ChromaticAberration(p=0.5, 
                          primary_distortion_limit=0.5, 
                          secondary_distortion_limit=0.1, 
                          mode='random'),
    A.GaussNoise(p=0.5)
])
Enter fullscreen mode Exit fullscreen mode

Complex Augmentation

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay