Created
September 21, 2012 21:05
-
-
Save gashtio/3763887 to your computer and use it in GitHub Desktop.
Creating a 3D LUT from a set of cubic splines, obtained from an acv file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const size_t CUBE_SIZE = 16; | |
std::vector<float> red(CUBE_SIZE); | |
std::vector<float> green(CUBE_SIZE); | |
std::vector<float> blue(CUBE_SIZE); | |
for (size_t i = 0; i < CUBE_SIZE; ++i) | |
{ | |
float input = (float)i / (float)(CUBE_SIZE - 1); | |
float input255 = input * 255.0f; | |
float redValue = clamp(cubicSplines[1].ComputeAtPoint(input255), 0.0f, 255.0f); | |
float greenValue = clamp(cubicSplines[2].ComputeAtPoint(input255), 0.0f, 255.0f); | |
float blueValue = clamp(cubicSplines[3].ComputeAtPoint(input255), 0.0f, 255.0f); | |
red[i] = saturate(cubicSplines[0].ComputeAtPoint(redValue) / 255.0f); | |
green[i] = saturate(cubicSplines[0].ComputeAtPoint(greenValue) / 255.0f); | |
blue[i] = saturate(cubicSplines[0].ComputeAtPoint(blueValue) / 255.0f); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment