# comfyui_custom_nodes/colortools/log_transforms.py import numpy as np def srgb_to_linear(x): return np.where(x <= 0.04045, x/12.92, ((x+0.055)/1.055)**2.4) def rec709_to_linear(x): return np.where(x < 0.081, x/4.5, ((x+0.099)/1.099)**(1/0.45)) def linear_to_logc3(x): x = np.clip(x, 1e-6, 1.0) a,b,c,d,e,f,cut = 5.555556,0.052272,0.2471896,0.385537,5.367655,0.092809,0.010591 return np.where(x>cut, c*np.log10(a*x+b)+d, e*x+f) def linear_to_clog2(x): x = np.clip(x, 1e-6, 1.0) return np.log10(10*x + 0.01) / np.log10(10.01) def linear_to_slog3(x): x = np.clip(x, 1e-6, 10.0) t = x * 10 return 0.432699 * np.log10(t + 0.037584) + 0.646596 def linear_to_proreslog(x): x = np.clip(x, 1e-6, 1.0) return np.log10(14*x + 0.01) / np.log10(14*1.0 + 0.01)