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 Image 或 Tensor