Skip to content
class

ToGray

extends_NoParamsPhotometricTransform[Empty]
ToGray(p: float = 0.5)

Convert an RGB image to grayscale while keeping 3 channels (Albumentations ToGray).

Applies the BT.601 luminance weights Y = 0.299 R + 0.587 G + 0.114 B and broadcasts the scalar luminance back to a 3-channel image so downstream ops that expect RGB still work. Delegates to functional.rgb_to_grayscale with keep_channels=True.

Parameters

pfloat= 0.5
Probability of applying the transform.

Examples

>>> import lucid
>>> import lucid.utils.transforms as T
>>> tf = T.ToGray(p=1.0)
>>> out = tf(T.Image(lucid.rand(3, 32, 32))).data
>>> tuple(out.shape)
(3, 32, 32)

Used by 1

Constructors

1
dunder

__init__

→None
__init__(p: float = 0.5)

Instance methods

1
fn

make_params

→Emptyfrom _NoParams
make_params(img: Tensor)

Dunder methods

1