Re: [Lcms-user] Creating equivalent matrix-shaper and 3D LUT profiles, problem with BPC
An ICC-based CMM for color management
Brought to you by:
mm2
|
From: <mar...@li...> - 2024-03-15 17:54:03
|
Hi Paalanen,
Nice to contact you. Regarding your question, matrix shaper is only a very
limited subset, true ICC profiles uses CLUT. Also, matrix shaper does not
allow gamut mapping so it is better to avoid matrix-shaper whatever
possible.
I think there is a much better solution than replicating all lcms internals.
You have to implement thetrahedral interpolation on GPU. It is not a big
deal, in CUDA and OpenCL is trivial. You can use the lcms code as basis.
Then, when you want to do color management, just create a color transform
and sample all RGB to RGB gamut in a CLUT of 33 points. You could use more
points if wish so, but 33 is enough in most cases. Ignore the profiles
internals, it is nothing of your business:
cmsOpenProfileFromFile input
cmsOpenProfileFromFile output
cmsCreateTransform input to output in floating point float
for (r=0; r<255; r += 256/33)
for (g=0; g<255; g += 256/33)
for (b=0; b<255; b += 256/33)
{
cmsDoTransform rgb -> rgb_out
store in GPU CLUT
}
Close everything
Then, when you want to transform an image, just use this CLUT and
tethahedral interpolation to do the color matching. It is fast because it
happens in the GPU. It is simple because you have not to worry about the
internal representation of the profiles. It is scalable because you can add
more points to increase precision and it is portable. And all color
management features are working.
Don't mess with DToBxx neither with matrix shaper, otherwise you would end
replicating all lcms functionality. Don't try to oversimplify by using
matrix-shaper, those are not good for gamut mapping and have no intents.
Color management does not work by using matrix shaper.
Hope that helps
Marti Maria
The LittleCMS Project
https://www.littlecms.com
uetiwonder why are you takin such huge amount
> -----Original Message-----
> From: Pekka Paalanen <pek...@ha...>
> Sent: Friday, March 15, 2024 11:23 AM
> To: lcm...@li...
> Subject: [Lcms-user] Creating equivalent matrix-shaper and 3D LUT
profiles,
> problem with BPC
>
> Hi,
>
> I'm working on a Wayland compositor (Weston) to integrate LittleCMS in it.
I
> use LittleCMS to come up with the color transformation from ICC profiles,
> then extract and optimize the cmsPipeline, and implement it in OpenGL ES
3.0
> shaders.
>
> I have some difficulty in generating ICC profiles in Weston's test suite.
I want
> the test suite to exercise all code paths to ensure the color operations
are
> implemented correctly. I have separate code paths for matrices+curves and
3D
> LUTs. Which code path gets chosen depends on what processing blocks
> (cmsStage) an ICC file results in. Therefore, I would like to craft
identically
> behaving ICC files that hit the different code paths (the goal).
>
> Crafting matrix-shaper profiles is easy. Crafting an equivalent profile
that
> internally has a 3D LUT (DToB/BToD) is the problem. I can craft such an
ICC
> profile, but because I need to test with the perceptual rendering intent,
I
> should also include BPC between the zeros black point of a matrix-shaper
and
> the non-zero black point of the v4 perceptual PCS. Otherwise the
assumption
> that a perceptual v4 CLUT profile has the ICCv4 defined perceptual black
point
> does not hold, and the tests fail.
>
> Is my goal reasonable to begin with, or should I just accept that
exercising the
> different Weston GL ES code paths by means of different ICC profiles
cannot
> lead to identical results and I need to define my expected test results
> separately for each case?
>
> If my goal is reasonable, then what would be a good way to add the
required
> BPC? Can I make LittleCMS compute it for me, or should I just copy the BPC
> algorithm from LittleCMS?
>
> I've tried creating the DToB/BToD test profile 3D LUT by creating a chain
of the
> usual matrix-shaper profile and the abstract XYZ profile and sampling
that, but
> now I'm convinced that I cannot get BPC applied that way, not with the XYZ
> profile at least.
>
>
> Thanks,
> pq
|