Sepia#

Sepia multiplies the RGB channels of a (*, 3, H, W) image by a fixed matrix; rescale divides by the image’s maximum.

Functions#

kornia.color.sepia(input, rescale=True, eps=1e-6)[source]#

Apply the sepia filter to an RGB image.

out = sepia(input) multiplies the RGB channels of a (*, 3, H, W) image by a fixed sepia matrix. By default it then divides by the image’s largest output value.

Convention:
  • rescale uses one maximum per image, over channels and pixels, so the tint is preserved.

  • Without rescale the output is the raw matrix response and can exceed 1.

Parameters:
  • input (Tensor) – RGB image with shape (*, 3, H, W).

  • rescale (bool, optional) – if True, divide by the maximum. Default: True

  • eps (float, optional) – constant added to the maximum, so a black image does not divide by zero. Default: 1e-6

Return type:

Tensor

Returns:

Sepia image with shape (*, 3, H, W).

See also

  • Sepia: the module form, with rescale and eps stored.

Example

>>> from kornia.color import sepia
>>> input = torch.ones(3, 1, 1)
>>> sepia(input, rescale=False)
tensor([[[1.3510]],

        [[1.2030]],

        [[0.9370]]])

Modules#

class kornia.color.Sepia(rescale=True, eps=1e-6)[source]#

Apply the sepia filter with stored settings (module form).

filt = Sepia(rescale, eps) stores the settings, and out = filt(input) is sepia() on a (*, 3, H, W) image.

Convention:
  • See the convention block of sepia().

Parameters:
  • rescale (bool, optional) – if True, divide by the per-image maximum. Default: True

  • eps (float, optional) – constant added to the maximum. Default: 1e-6

See also

Example

>>> input = torch.ones(3, 1, 1)
>>> Sepia(rescale=False)(input)
tensor([[[1.3510]],

        [[1.2030]],

        [[0.9370]]])