MATLAB: How to extract X and Y channel

color spaceimage processingImage Processing Toolbox

I want to extract X and Y channel (CIE 1931 XYZ color space) from an RGB image. How should I do that? Thanks in advance.

Best Answer

You can find the "book formulas" here: http://easyrgb.com/index.php?X=MATH&H=02#text2
The built-in function to do rgb-to-xyz conversion is in the Image Processing Toolbox:
xyz = rgb2xyz(rgb)
Of course that's not calibrated - it's somewhat arbitrary. The XYZ color of a material is intrinsic to that material. However you can get almost any RGB you want just by fiddling with your camera settings. For example if I reduce my exposure by half, my XYZ will be half as big yet the material you took a picture of didn't change at all, and if you measured XYZ on a spectrophotometer you'd see that the XYZ is the same before your first photo and before your second photo. So the XYZ you get out of "book formula" are not the same as you'd get from a spectrophotometer (the gold standard for color measurements).