MCPcopy Create free account
hub / github.com/apple/ml-pointersect / srgb_to_linear

Function srgb_to_linear

plib/render.py:914–927  ·  view source on GitHub ↗

Converts an image from sRGB to Linear colorspace. We treat each pixel independently (to color channels as well). Args: x: (*,) image in sRGB space. Returns: (*,) converted image

(x: torch.Tensor)

Source from the content-addressed store, hash-verified

912
913
914def srgb_to_linear(x: torch.Tensor):
915 """
916 Converts an image from sRGB to Linear colorspace.
917 We treat each pixel independently (to color channels as well).
918
919 Args:
920 x:
921 (*,) image in sRGB space.
922
923 Returns:
924 (*,) converted image
925 """
926 limit = 0.04045
927 return torch.where(x > limit, torch.pow((x + 0.055) / 1.055, 2.4), x / 12.92)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected