灰度¶
- class torchvision.transforms.Grayscale(num_output_channels=1)[原始碼]¶
將影像轉換為灰度圖。如果影像是 torch Tensor,則其形狀應為 […, 3, H, W],其中 … 表示任意數量的前導維度
- 引數:
num_output_channels (int) – (1 或 3) 輸出影像所需的通道數
- 返回:
輸入的灰度版本。
如果
num_output_channels == 1: 返回的影像為單通道如果
num_output_channels == 3: 返回的影像為 3 通道,其中 r == g == b
- 返回型別:
PIL Image
使用
Grayscale的示例