ChannelShuffle
Targets:
image
Image Types:uint8, float32
Permute image channels. By default the permutation is random (uniform over all
orderings); set channel_order to pin a fixed reordering.
Arguments
channel_ordertuple[int, ...] | None
Fixed permutation of channel indices.
When None (default), a random permutation is sampled each call.
When a tuple, that exact order is applied every time (length must match
the number of image channels).
Default: None.
pfloat
0.5
Probability of applying the transform. Default: 0.5.
Examples
>>> import numpy as np
>>> import albumentations as A
>>> image = np.random.randint(0, 256, (100, 100, 3), dtype=np.uint8)
>>>
>>> # Random shuffle (default)
>>> transform = A.ChannelShuffle(p=1.0)
>>> result = transform(image=image)["image"]
>>>
>>> # Fixed reorder: RGB → BGR
>>> transform = A.ChannelShuffle(channel_order=(2, 1, 0), p=1.0)
>>> result = transform(image=image)["image"]Notes
- When
channel_orderisNone, the permutation is chosen uniformly over all channel orderings; the same image can get different orderings on different calls. - When
channel_orderis set, the transform behaves deterministically (same asChannelSwap).
See Also
- ChannelSwap: Convenience alias with
channel_orderrequired.