日光化層

[原始碼]

Solarization 類別

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

對圖像中的每個像素應用 (max_value - pixel + 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]