Custom RGB color space

18 views (last 30 days)
Roger Breton
Roger Breton on 23 Feb 2024
Commented: Roger Breton on 9 Sep 2024
I am plottiing the measured Lab colors of a ColorChecker SG chart in 3D as you can see below:
To obtain the "gamut surface", I use the following code:
[r,g,b] = meshgrid(linspace(0,1,20)); % linspace(0,1,50)
rgb = [r(:), g(:), b(:)];
lab = rgb2lab(rgb, 'ColorSpace', 'adobe-rgb-1998', 'WhitePoint','d50');
a = lab(:,2);
b = lab(:,3);
L = lab(:,1);
k = boundary(a,b,L);
h1 = trisurf(k,a,b,L,'FaceColor','interp', 'FaceVertexCData',rgb,'EdgeColor','none', 'FaceAlpha', 0.30);
Works great as it allows me to analyze how the ColorChecker SG chart "fit" inside a given RGB color space such as AdobeRGB. But as you can see by the screen capture, some points lie outside the AdobeRGB gamut? I don't want to use ProPhotoRGB as I find it is so "big" (I'm still not sold on it).
My question is: would there be any way for me to specify custom primaries? As in Photoshop?
The goal would be to find which primaries are capable of fully enclosing my ColorChecker SG colors and give me the "best" editing space to transform my RGB images from my Nikon to Photoshop using a custom camera profile.
Thanks in advance for your help.

Accepted Answer

Aastha
Aastha on 4 Sep 2024
Hi Roger Breton,
I understand that you want to specify custom values for gamma, whitepoint, and RGB primaries for the rgb2lab function instead of using the built-in templates.
However, according to the MathWorks documentation of “rgb2lab” function only built-in templates can be specified. Here is the link to the documentation of “rgb2lab” function:
I tried to implement a manual conversion process which could adjust the parameters according to user specifications. You may find my custom implementation in the attached file “custom_primaries.m”. I have also compared this custom implementation with MATLAB’s built-in rgb2lab function using the "adobe-rgb-1998" template for your reference.
You can replace the built-in rgb2lab function in your code with this custom rgb_to_lab” function implementation within the “custom_primaries.m” script to visualize the ColorCheckerSG chart and identify the primaries that best fit your image. You can then adjust the primaries, whitepoint, and gamma according to your specifications to achieve the best results.
I hope this helps!
  1 Comment
Roger Breton
Roger Breton on 9 Sep 2024
Thank you very much for your kind help!

Sign in to comment.

More Answers (0)

Products


Release

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!