Sunday, July 14, 2013

How to convert RGB to XYZ or vice versa

How to convert RGB to XYZ or vice versa?

Conversion matrices can be found here
http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html


% You need MATLAB or Octave to run this 
% Let say you have one color and its pure red 
red=[255;0;0] 
% now, you can convert it to XYZ assuming rec 709 display and D65 white 
% point using the following matrix 
RGB2XYZ=[0.4124564 0.3575761 0.1804375 0.2126729 0.7151522 0.0721750 0.0193339 0.1191920 0.9503041]; redXYZ=RGB2XYZ*red; 
 %now, you can normalize it further so that Y=100 r
edXYZ=redXYZ/redXYZ(2)*100; 
% this is the final result 
redXYZ = 193.9393 100.0000 9.0909

No comments:

Post a Comment

Please ask if anything is not clear enough..........