RandomSolarize¶ class torchvision.transforms.RandomSolarize(threshold, p=0.5)[source]¶ 以给定概率随机地对图像进行 Solarize 处理,方法是将所有高于阈值的像素值反转。如果 img 是 Tensor,则应为 […, 1 或 3, H, W] 格式,其中 … 表示它可以具有任意数量的前导维度。如果 img 是 PIL Image,则应为 “L” 或 “RGB” 模式。 参数: threshold (float) – 高于或等于此值的所有像素都将反转。 p (float) – 图像进行 Solarize 处理的概率。默认值为 0.5 使用 RandomSolarize 的示例 变换的图示 变换的图示 forward(img)[source]¶ 参数: img (PIL Image 或 Tensor) – 要进行 Solarize 处理的图像。 返回: 随机 Solarize 处理后的图像。 返回类型: PIL Image 或 Tensor