RandomPosterize¶ class torchvision.transforms.RandomPosterize(bits, p=0.5)[源代码]¶ 通过以给定概率随机锐化图像,减少每个颜色通道的位数。如果图像是 torch Tensor,则其类型应为 torch.uint8,并且期望其形状为 [..., 1 或 3, H, W],其中 ... 表示任意数量的前导维度。如果 img 是 PIL Image,则期望其模式为“L”或“RGB”。 参数: bits (int) – 为每个通道保留的位数(0-8) p (float) – 图像被锐化的概率。默认值为 0.5 使用 RandomPosterize 的示例 转换图示 转换图示 forward(img)[源代码]¶ 参数: img (PIL Image 或 Tensor) – 要锐化的图像。 返回: 随机锐化后的图像。 返回类型: PIL 图像或张量