Shortcuts

随机海报化

class torchvision.transforms.v2.RandomPosterize(bits: int, p: float = 0.5)[source]

通过减少每个颜色通道的位数,以给定的概率对图像或视频进行海报化处理。

如果输入是torch.Tensor,它应该是torch.uint8类型, 并且期望具有[…, 1或3, H, W]形状,其中…表示任意数量的前导维度。 如果img是PIL图像,则期望其模式为“L”或“RGB”。

Parameters:
  • bits (int) – 每个通道保留的位数 (0-8)

  • p (float) – 图像被海报化的概率。默认值为0.5

使用RandomPosterize的示例:

变换的图示

Illustration of transforms