Color sweeps
CCT sweep
import torch
from tinycio import Chromaticity, ColorImage, WhiteBalance
res = []
width = 800
for x in range(width):
cct = x / width * 21000 + 4000
xy = Chromaticity(WhiteBalance.wp_from_cct(cct))
col = xy.to_xyz(0.75)
res.append(col.image())
out = ColorImage(torch.cat(res, dim = 2).repeat(1, 50, 1), 'CIE_XYZ')
out.to_color_space('SRGB').clamp(0., 1.).save('../out/sweep_cct.png')

Illuminant sweep
import torch
from tinycio import Chromaticity, ColorImage, WhiteBalance
res = []
width = 800
illum = WhiteBalance.Illuminant.TUNGSTEN
illum_xy = Chromaticity(WhiteBalance.wp_from_illuminant(illum))
light_scale, dist_scale = 2000., 1000.
for x in range(width):
col = illum_xy.to_xyz(light_scale * (1./(((x / width) * dist_scale)**2 + 1.)))
res.append(col.image())
out = ColorImage(torch.cat(res, dim = 2).repeat(1, 50, 1).clamp(0., 1.), 'CIE_XYZ')
out.to_color_space('SRGB').save('../out/sweep_illuminant.png')

Visible spectrum sweep
import torch
from tinycio import Color, ColorImage, Spectral
res = []
width = 800
for x in range(width):
wl = (x / width) * 400 + 380
res.append(Color(Spectral.wl_to_srgb_linear(wl, normalize=False)).image())
out = ColorImage(torch.cat(res, dim = 2).repeat(1, 50, 1), 'SRGB_LIN').clamp(0., 1.)
out.to_color_space('SRGB').save('../out/sweep_spectrum.png')

HSL hue sweep
import torch
from tinycio import Color, ColorImage
res = []
width = 800
col = Color(1, 1, 0.5)
for x in range(width):
col.x = (x / width + 0.5) % 1
res.append(col.image())
out = ColorImage(torch.cat(res, dim = 2).repeat(1, 50, 1).clamp(0., 1.), 'HSL')
out.to_color_space('SRGB').save('../out/sweep_hue_hsl.png')

OKLAB hue sweep
import torch
from tinycio import Color, ColorImage
from tinycio.util import apply_hue_oklab
res = []
width = 800
for x in range(width):
im = Color(1, 0, 0).image('SRGB_LIN').to_color_space('OKLAB')
res.append(apply_hue_oklab(im, x / width * 2. - 1))
out = ColorImage(torch.cat(res, dim = 2).repeat(1,50,1), 'OKLAB')
out.to_color_space('SRGB').save('../out/sweep_hue_oklab.png')
