Stretch intensity to full range (autocontrast). method: CDF or PIL-style. cutoff, ignore trim extremes. Use for normalizing brightness/contrast across images.
This transform provides two methods for contrast enhancement:
The transform can optionally exclude extreme values from both ends of the intensity range and preserve specific intensity values (e.g., alpha channel).
cutoffPercentage of pixels to exclude from both ends of the histogram. Range: [0, 100]. Default: 0 (use full intensity range)
ignoreIntensity value to preserve (e.g., alpha channel). Range: [0, 255]. Default: None
methodAlgorithm to use for contrast enhancement. Default: "cdf"
pProbability of applying the transform. Default: 0.5
>>> import albumentations as A
>>> # Basic usage
>>> transform = A.AutoContrast(p=1.0)
>>>
>>> # Exclude extreme values
>>> transform = A.AutoContrast(cutoff=20, p=1.0)
>>>
>>> # Preserve alpha channel
>>> transform = A.AutoContrast(ignore=255, p=1.0)
>>>
>>> # Use PIL-like contrast enhancement
>>> transform = A.AutoContrast(method="pil", p=1.0)