tetra.mp4
Tesselates a tetrahedral mesh out of a 3D scattered point cloud using Delaunay triangulation, and uses a Barycentric coordinate-based trilinear interpolation to map it into a regularly-spaced 3D grid, for use as a 3D Cube Color LUT
I made this as a stepping stone to interpolating 3D point cloud data into a 3D grid, specifically for creating color LUTs It's a one-time operation so it didn't really need to be all that efficient. The way that made the most sense to me was to convert the cartesian coordinates to barycentric coordinates, for which I made a little visual demo to help me understand them.
Give it two files, src and tgt. they're each 3-by-n float arrays in text form, 3 decimal numbers per line, where each line of src maps to the same line in tgt, so the files should be the same length. Anything outside of the resulting tetrahedral mesh is mapped to 0, 0, 0 (black). Extrapolation is a whole other deal for a later day maybe.
The output is test.cube. For development everything's still configured through variables, so lut_res is fixed at 33 but that's the standard and is fine for most cases. You can set it to 65 if you need more res or 15 if you're really cramped on space.
I might add command line options in the future if there's interest. PRs appreciated!
I was inspired by Steve Yedlin's videos and articles on color science where he used a similar method to correlate color data captured on film, to the same data captured on a digital camera sensor. The resulting data is irregularly spaced and can be represented in 3D as a scattered point cloud, but virtually all color correction software uses regularly-spaced, grid-based 33x33x33 (or other sizes) cube LUTs for easier GPU processing.
This is an early step in my journey of investigating more advanced color science techniques than those typically available in industry standard commercial software. We have so much control with digital imaging these days and, although we do a lot of crazy stuff, truth be told, we hardly use any of that control! Much like Steve, my one true love is the classic Hollywood film look, but I think there's plenty more to be explored here!