So I was making a RGB to XYZ conversion and I came to position where I don’t understand the results I am seeing.
According to Easy RGB you do the conversion from sRGB to XYZ by using:
# XYZ def rgb_to_xyz(self, r, g, b):# CORRECT ? if ( r > 0.04045 ): r = ( ( r + 0.055 ) / 1.055 ) ** 2.4 else: r = r / 12.92 if ( g > 0.04045 ): g = ( ( g + 0.055 ) / 1.055 ) ** 2.4 else: g = g / 12.92 if ( b > 0.04045 ): b = ( ( b + 0.055 ) / 1.055 ) ** 2.4 else: b = b / 12.92 x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805) y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722) z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505) return [x, y, z] def xyz_to_rgb(self, x, y, z):# CORRECT ? var_r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986) var_g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415) var_b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570) if var_r > 0.0031308: r = 1.055 * ( var_r ** ( 1 / 2.4 ) ) - 0.055 else: r = 12.92 * var_r if var_g > 0.0031308: g = 1.055 * ( var_g ** ( 1 / 2.4 ) ) - 0.055 else: g = 12.92 * var_g if var_b > 0.0031308: b = 1.055 * ( var_b ** ( 1 / 2.4 ) ) - 0.055 else: b = 12.92 * var_b return [r, g, b]
I checked with the Colorizer site and the code is good. The results are good going back and forth but they are not the same used in Krita for some reason.
Openning a RGB file I place a color on the canvas and using the advanced color selector I change the mode to XYZ to see the code of the color I just used and they don’t match.
I have used standard RGB and adobe RGB with different results from Krita so I am a bit of a loss.
Also I am not able to locate the file that contains the RGB to XYZ code within Krita. XYZ to LAB is also not found so I imagine there might be some issues with it too since I can’t find it.
My issue is that I could use this code instead but it starts to fight Krita heavily when it updates side by side.