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
的示例