Shortcuts

随机曝光

class torchvision.transforms.RandomSolarize(threshold, p=0.5)[source]

以给定的概率随机对图像进行曝光处理,通过反转所有高于阈值的像素值。如果img是Tensor,则期望其格式为[…, 1或3, H, W],其中…表示它可以有任意数量的前导维度。如果img是PIL图像,则期望其模式为“L”或“RGB”。

Parameters:
  • threshold (float) – 所有等于或高于此值的像素将被反转。

  • p (float) – 图像被太阳化的概率。默认值为0.5

使用 RandomSolarize 的示例:

变换的图示

Illustration of transforms
forward(img)[source]
Parameters:

img (PIL ImageTensor) – 要进行曝光的图像。

Returns:

随机日晒图像。

Return type:

PIL 图像或张量