posterize¶
- torchvision.transforms.functional.posterize(img: Tensor, bits: int) Tensor[source]¶
通过减少每个颜色通道的位数来对图像进行色调分离。
- Parameters:
img (PIL Image 或 Tensor) – 需要对其颜色进行分色的图像。 如果 img 是 torch Tensor,它应该是 torch.uint8 类型,并且 预期为 […, 1 或 3, H, W] 格式,其中 … 表示 它可以有任意数量的前导维度。 如果 img 是 PIL Image,预期为模式 “L” 或 “RGB”。
bits (int) – 每个通道保留的位数(0-8)。
- Returns:
海报化图像。
- Return type:
PIL 图像或张量
使用
posterize的示例: