Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I get Look up table or conversion matrix in cmsHTRANSFORM #94

Closed
lazysquid opened this issue Aug 12, 2016 · 1 comment
Closed

Comments

@lazysquid
Copy link

lazysquid commented Aug 12, 2016

Hello. I'm trying to apply CMS to my renderer which is implemented using OpenGL.

Specifically I supposed generated image in GPU buffer(rendered image) is in sRGB space and I'm trying to convert that image into my monitor's RGB space inside of my fragment shader.

So I made simple transform which looks like this.

hTransform = cmsCreateTransform(profile_sRGB, TYPE_BGR_8, profile_leftMonitor, TYPE_BGR_8, INTENT_PERCEPTUAL, 0);

To accomplish CMS inside of GPU I should send matrix or LUT as form of uniform variable. So that my fragment shader can access to information about color transform .

I have basic knowldege about CMS so I thought cmsHTRANSFORM has some sort of conversion matrix or look up table to compute source to target RGB conversion.

So first thing that I tried to find was 3x3(or 4x4) conversion matrix or look up table
which convert RGB in color space A to RGB in color space B in cmsHTRANSFORM.
But I couldn't find anything like that in API documents.
Maybe I don't know the keyword related to it.
Does LCMS support LUT or 3x3 conversion matrix?

If not, is there any way to achieve CMS in my renderer?

@mm2
Copy link
Owner

mm2 commented Aug 12, 2016

Hi, what you intend to do is easy. Once you got the RGB8 to RGB8 transform, you can create a LUT table by sampling it at regular intervals. Something like:

for (r=0; r < 256; r += 16)
for (g=0; g < 256; g+=16)
for (b=0; b < 256; b+=16)
{
put r, g, b into rgb[] table
cmsDoTransform(rgb, rgb_out, 1);
keep rgb_out as LUT node
}

Then upload the LUT to the GPU and perform trilinear interpolation.

Those folks from media player classic are using this way:
https://voxelium.wordpress.com/2010/09/20/icc-color-management-in-media-player-classic-home-cinema/

Regards

@mm2 mm2 closed this as completed Aug 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants