RandomGrayscale¶
- class mmcv.transforms.RandomGrayscale(prob: float = 0.1, keep_channels: bool = False, channel_weights: Sequence[float] = (1.0, 1.0, 1.0), color_format: str = 'bgr')[源代码]¶
Randomly convert image to grayscale with a probability.
Required Key:
img
Modified Key:
img
Added Keys:
grayscale
grayscale_weights
- 参数
prob (float) – Probability that image should be converted to grayscale. Defaults to 0.1.
keep_channels (bool) – Whether keep channel number the same as input. Defaults to False.
channel_weights (tuple) – The grayscale weights of each channel, and the weights will be normalized. For example, (1, 2, 1) will be normalized as (0.25, 0.5, 0.25). Defaults to (1., 1., 1.).
color_format (str) – Color format set to be any of ‘bgr’, ‘rgb’, ‘hsv’. Note: ‘hsv’ image will be transformed into ‘bgr’ format no matter whether it is grayscaled. Defaults to ‘bgr’.