Create an RGB -> RGB transform and re-sample it on a regular grid,
for instance like below (code is a bit older, still using lcms1, though).
Regards,
Gerhard
#define GRIDPOINTS 64
static GLushort clut[GRIDPOINTS][GRIDPOINTS][GRIDPOINTS][3];
static GLuint img_texture;
static GLuint clut_texture;
static GLfloat clut_scale;
static GLfloat clut_offset;
void
make_clut_texture(const char *profile_name)
{
int r, g, b, n = GRIDPOINTS;
cmsHPROFILE sRGB, monitor;
cmsHTRANSFORM xform;
sRGB = cmsCreate_sRGBProfile (); // image profile
monitor = cmsOpenProfileFromFile (profile_name, "r");
if (monitor == NULL) {
fprintf(stderr, "Cannot open display profile %s\n", profile_name);
exit(1);
}
xform = cmsCreateTransform (sRGB, TYPE_RGB_16, monitor, TYPE_RGB_16,
INTENT_PERCEPTUAL, cmsFLAGS_NOTPRECALC);
if (xform == NULL) {
fprintf(stderr, "Failed to create transformation\n");
exit(1);
}
clut_scale = (double) (n - 1) / n;
clut_offset = 1.0 / (2 * n);
for (r = 0; r < n; r++) {
for (g = 0; g < n; g++) {
for (b = 0; b < n; b++) {
unsigned short in[3];
in[0] = floor ((double) r / (n - 1) * 65535.0 + 0.5);
in[1] = floor ((double) g / (n - 1) * 65535.0 + 0.5);
in[2] = floor ((double) b / (n - 1) * 65535.0 + 0.5);
cmsDoTransform (xform, in, clut[b][g][r], 1);
}
}
}
cmsDeleteTransform (xform);
cmsCloseProfile (monitor);
cmsCloseProfile (sRGB);
glGenTextures (1, &clut_texture);
/* texture 1 = clut */
glActiveTextureARB (GL_TEXTURE0_ARB + 1);
glBindTexture (GL_TEXTURE_3D, clut_texture);
glTexParameteri (GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri (GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameteri (GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP);
glTexParameteri (GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri (GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage3D (GL_TEXTURE_3D, 0, GL_RGB16, n, n, n,
0, GL_RGB, GL_UNSIGNED_SHORT, clut);
/* back to texture 0 = image */
glActiveTextureARB (GL_TEXTURE0_ARB);
}
Am 10.03.2015 um 00:09 schrieb Terence Tay:
Marti,
That is an interesting idea. Could you point out the relevant LCMS calls and
documentation to generate a 3D LUT from an ICC profile?
Terence
On Fri, Mar 6, 2015 at 6:08 PM, <marti.ma...@littlecms.com
<mailto:marti.ma...@littlecms.com>> wrote:
Quoting Noel Carboni <ncarb...@prodigitalsoftware.com
<mailto:ncarb...@prodigitalsoftware.com>>:
> Speaking of what the Adobe Color Engine can do... Is anyone
> considering porting Little CMS transformations to run on a GPU? :-)
Hi,
The trick is to use lcms2 to create a 3D Lut and then use the GPU and
trilinear interpolation. I think Media Player Classic is doing that.
Regards
Marti
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website,
sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for
all
things parallel software development, from weekly thought leadership blogs
to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Lcms-user mailing list
Lcms-user@lists.sourceforge.net <mailto:Lcms-user@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/lcms-user
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Lcms-user mailing list
Lcms-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lcms-user
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Lcms-user mailing list
Lcms-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lcms-user