posterize¶
- torchvision.transforms.functional.posterize(img: Tensor, bits: int) Tensor [源代码]¶
通过减少每个颜色通道的位数来将图像风格化。
- 参数:
img (PIL Image 或 Tensor) – 要风格化的图像。如果 img 是 torch Tensor,则它应该是 torch.uint8 类型,并且预期格式为 [..., 1 或 3, H, W],其中 ... 表示它可以有任意数量的前导维度。如果 img 是 PIL Image,则预期模式为 “L” 或 “RGB”。
bits (int) – 为每个通道保留的位数(0-8)。
- 返回:
风格化后的图像。
- 返回类型:
PIL 图像或张量
使用
posterize
的示例