From: Max Value Date: Tue, 7 Oct 2025 17:47:37 +0000 (+0100) Subject: Switched to scipy B splines X-Git-Url: https://git.ozva.co.uk/?a=commitdiff_plain;h=34784b330383a0cb8dde218d4a2f62e4a64090a8;p=rust_fft Switched to scipy B splines --- diff --git a/src/cube/cube.py b/src/cube/cube.py index ba6cf6f..dadd661 100755 --- a/src/cube/cube.py +++ b/src/cube/cube.py @@ -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 diff --git a/src/cube/frame.py b/src/cube/frame.py index d331c2e..b8850aa 100644 --- a/src/cube/frame.py +++ b/src/cube/frame.py @@ -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