#!.venv/bin/python
+from scipy.interpolate import make_interp_spline
from tqdm import tqdm
import numpy as np
import cv2 as cv
for i in range(self.size * self.size):
seq = np.linspace(0, 255, self.size)
- c[i] = np.interp(seq, c[i], seq)
+ """
+ This is the section that does all the heavy lifting by reinterpolating the curves
+ at the right ordinates. scipy b splines should work better but might introduce
+ strange loops in weird color situations.
+ """
+
+ spl = make_interp_spline(c[i], seq)
+ c[i] = spl(seq)
+
+ # Alternative np splines
+
+ #c[i] = np.interp(seq, c[i], seq)
c = np.reshape(c, (self.size, self.size, self.size))
return c
def cast(a):
a = np.array(a, dtype=np.float64)
- a = ((a / 255.) ** 0.4) * 255.
+ a[...,0] = ((a[...,0] / 255.) ** 0.4) * 255.
+ a[...,1] = ((a[...,1] / 255.) ** 2) * 255.
+ a[...,2] = ((a[...,2] / 255.) ** 0.3) * 255.
a = np.clip(a.astype(np.uint8), 0, 255)
return a