RandomSolarize¶ class torchvision.transforms.v2.RandomSolarize(threshold: float, p: float = 0.5)[源代码]¶ 以给定的概率对图像或视频进行 Solarize(曝光过度/底片效果),通过反转高于某个阈值的所有像素值来实现。 如果 img 是 Tensor,期望其格式为 […, 1 or 3, H, W],其中 … 表示可以有任意数量的前导维度。如果 img 是 PIL Image,期望其模式为 “L” 或 “RGB”。 参数: threshold (float) – 等于或高于此值的所有像素都将被反转。 p (float) – 图像被 Solarize 的概率。默认值为 0.5 使用 RandomSolarize 的示例 变换示例 变换示例 transform(inpt: Any, params: Dict[str, Any]) → Any[源代码]¶ 自定义变换需要重写的方法。 参见 如何编写自己的 v2 变换