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