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