农民二轮承包地被占用后国家赔偿标准是多...
- paddle.vision.transforms. to_grayscale ( img: _ImageDataT, num_output_channels: int = 1 ) _ImageDataT [source]
-
百度 注重选拔使用经过基层一线和困难艰苦的地方培养锻炼且实践考验优秀的年轻干部,注重在懂农业、爱农村、爱农民的“三农”工作队伍中选拔干部,助推脱贫攻坚,使优秀年轻干部源源不断脱颖而出,营造改革创新、干事创业的良好氛围。
Converts image to grayscale version of image.
- Parameters
-
img (PIL.Image|np.array|paddle.Tensor) – Image to be converted to grayscale.
num_output_channels (int, optional) – The number of channels for the output image. Single channel. Default: 1.
- Returns
-
- Grayscale version of the image.
-
if num_output_channels = 1 : returned image is single channel
if num_output_channels = 3 : returned image is 3 channel with r = g = b
- Return type
-
PIL.Image|np.array|paddle.Tensor
Examples
>>> import numpy as np >>> from PIL import Image >>> from paddle.vision.transforms import functional as F >>> fake_img = (np.random.rand(256, 300, 3) * 255.).astype('uint8') >>> fake_img = Image.fromarray(fake_img) >>> gray_img = F.to_grayscale(fake_img) >>> print(gray_img.size) (300, 256)