ChromaticAberration
Add lateral chromatic aberration by distorting the red and blue channels of the input image.
Chromatic aberration is an optical effect that occurs when a lens fails to focus all colors to the same point. This transform simulates this effect by applying different radial distortions to the red and blue channels of the image, while leaving the green channel unchanged.
primary_distortion_limitRange of the primary radial distortion coefficient. If a single float value is provided, the range will be (-primary_distortion_limit, primary_distortion_limit). This parameter controls the distortion in the center of the image:
- Positive values result in pincushion distortion (edges bend inward)
- Negative values result in barrel distortion (edges bend outward) Default: (-0.02, 0.02).
secondary_distortion_limitRange of the secondary radial distortion coefficient. If a single float value is provided, the range will be (-secondary_distortion_limit, secondary_distortion_limit). This parameter controls the distortion in the corners of the image:
- Positive values enhance pincushion distortion
- Negative values enhance barrel distortion Default: (-0.05, 0.05).
modeType of color fringing to apply. Options are:
- 'green_purple': Distorts red and blue channels in opposite directions, creating green-purple fringing.
- 'red_blue': Distorts red and blue channels in the same direction, creating red-blue fringing.
- 'random': Randomly chooses between 'green_purple' and 'red_blue' modes for each application. Default: 'green_purple'.
interpolationFlag specifying the interpolation algorithm. Should be one of: cv2.INTER_NEAREST, cv2.INTER_LINEAR, cv2.INTER_CUBIC, cv2.INTER_AREA, cv2.INTER_LANCZOS4. Default: cv2.INTER_LINEAR.
pProbability of applying the transform. Should be in the range [0, 1]. Default: 0.5.
>>> import albumentations as A
>>> import cv2
>>> transform = A.ChromaticAberration(
... primary_distortion_limit=0.05,
... secondary_distortion_limit=0.1,
... mode='green_purple',
... interpolation=cv2.INTER_LINEAR,
... p=1.0
... )
>>> transformed = transform(image=image)
>>> aberrated_image = transformed['image']- This transform only affects RGB images. Grayscale images will raise an error.
- The strength of the effect depends on both primary and secondary distortion limits.
- Higher absolute values for distortion limits will result in more pronounced chromatic aberration.
- The 'green_purple' mode tends to produce more noticeable effects than 'red_blue'.
- Chromatic Aberrationhttps://en.wikipedia.org/wiki/Chromatic_aberration