PlasmaBrightnessContrast

Targets:
image
volume
Image Types:uint8, float32

Apply plasma fractal pattern to modify image brightness and contrast.

Uses Diamond-Square algorithm to generate organic-looking fractal patterns that create spatially-varying brightness and contrast adjustments.

Arguments
brightness_range
tuple[float, float]
[-0.3,0.3]

Range for brightness adjustment strength. Values between -1 and 1:

  • Positive values increase brightness
  • Negative values decrease brightness
  • 0 means no brightness change Default: (-0.3, 0.3)
contrast_range
tuple[float, float]
[-0.3,0.3]

Range for contrast adjustment strength. Values between -1 and 1:

  • Positive values increase contrast
  • Negative values decrease contrast
  • 0 means no contrast change Default: (-0.3, 0.3)
plasma_size
int
256

Size of the initial plasma pattern grid. Larger values create more detailed patterns but are slower to compute. The pattern will be resized to match the input image dimensions. Default: 256

roughness
float
3

Controls how quickly the noise amplitude increases at each iteration. Must be greater than 0:

  • Low values (< 1.0): Smoother, more gradual pattern
  • Medium values (~2.0): Natural-looking pattern
  • High values (> 3.0): Very rough, noisy pattern Default: 3.0
p
float
0.5

Probability of applying the transform. Default: 0.5.

Examples
>>> import albumentations as A
>>> import numpy as np

# Default parameters
>>> transform = A.PlasmaBrightnessContrast(p=1.0)

# Custom adjustments
>>> transform = A.PlasmaBrightnessContrast(
...     brightness_range=(-0.5, 0.5),
...     contrast_range=(-0.3, 0.3),
...     plasma_size=512,    # More detailed pattern
...     roughness=0.7,      # Smoother transitions
...     p=1.0
... )
Notes
  • Works with any number of channels (grayscale, RGB, multispectral)
  • The same plasma pattern is applied to all channels
  • Operations are performed in float32 precision
  • Final values are clipped to valid range [0, max_value]
See Also
  • RandomBrightnessContrast: For uniform brightness/contrast adjustments
  • CLAHE: For contrast limited adaptive histogram equalization
  • FancyPCA: For color-based contrast enhancement
  • HistogramMatching: For reference-based contrast adjustment
References
  • [{'description': 'Fournier, Fussell, and Carpenter, "Computer rendering of stochastic models,"', 'source': 'Communications of the ACM, 1982. Paper introducing the Diamond-Square algorithm.'}, {'description': 'Diamond-Square algorithm', 'source': 'https://en.wikipedia.org/wiki/Diamond-square_algorithm'}]