太阳化层

[source]

Solarization

keras.layers.Solarization(
    addition_factor=0.0, threshold_factor=0.0, value_range=(0, 255), seed=None, **kwargs
)

对图像中的每个像素应用 (max_value - 像素 + min_value)

当创建时没有 threshold 参数,该层对所有值执行太阳化处理。当使用指定的 threshold 创建时,该层仅增强高于 threshold 值的像素。

参数

  • addition_factor: (可选) 一个包含两个浮点数的元组或一个介于 0 和 1 之间的单个浮点数。对于每个增强的图像,从提供的范围中采样一个值。如果传递一个浮点数,则该范围被解释为 (0, addition_factor)。如果指定,则此值(乘以输入图像的值范围,例如 255)在太阳化和阈值化之前添加到每个像素。默认为 0.0。
  • threshold_factor: (可选) 一个包含两个浮点数的元组或一个单个浮点数。对于每个增强的图像,从提供的范围中采样一个值。如果传递一个浮点数,则该范围被解释为 (0, threshold_factor)。如果指定,则只有高于此阈值的像素值将被太阳化。
  • value_range: 一个包含两个元素的元组或列表。第一个值表示输入图像中值的下限,第二个值表示上限。传递给该层的图像应具有 value_range 范围内的值。要传递的典型值是 (0, 255) (RGB 图像) 或 (0., 1.) (缩放图像)。
  • seed: 整数。用于创建随机种子。
  • **kwargs: 基础层关键字参数,例如 namedtype

示例

(images, labels), _ = keras.datasets.cifar10.load_data()
print(images[0, 0, 0])
# [59 62 63]
# Note that images are Tensor with values in the range [0, 255]
solarization = Solarization(value_range=(0, 255))
images = solarization(images)
print(images[0, 0, 0])
# [196, 193, 192]