]> OzVa Git service - rust_fft/commitdiff
Switched to scipy B splines
authorMax Value <greenwoodw50@gmail.com>
Tue, 7 Oct 2025 17:47:37 +0000 (18:47 +0100)
committerMax Value <greenwoodw50@gmail.com>
Tue, 7 Oct 2025 17:47:37 +0000 (18:47 +0100)
src/cube/cube.py
src/cube/frame.py

index ba6cf6fd23742d61d863f1c57e6012d04fcffc89..dadd661bf0a4852b4faf9bb57f0e32f86b0d645d 100755 (executable)
@@ -1,5 +1,6 @@
 #!.venv/bin/python
 
+from scipy.interpolate import make_interp_spline
 from tqdm import tqdm
 import numpy as np
 import cv2 as cv
@@ -61,7 +62,18 @@ colors:\t{self.size**3}
                        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
index d331c2eae92c6ee43d243b281d0dc4859df033c2..b8850aacb73151300538efcf8d429c30a36d492e 100644 (file)
@@ -9,7 +9,9 @@ import os
 
 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