Search code examples
matlabcolor-space

the difference between makecform('srgb2xyz') and rgb2xyz() in matlab


I wonder what the matlab does when using the function rgb2xyz()? I cannot re-produce the results using the rgb2xyz conversion matrix.. Moreover, is there any difference between using makecform('srgb2xyz') and using rgb2xyz()? they produce difference results..


Solution

  • The default white point for makecform('srgb2xyz') appears to be D50, whereas rgb2xyz defaults to D65.

    >> applycform([.2 .3 .4],makecform('srgb2xyz','AdaptedWhitePoint',whitepoint('D65')))
    
    ans =
    
    0.0638    0.0690    0.1356
    
    >> rgb2xyz([.2 .3 .4])
    
    ans =
    
    0.0638    0.0690    0.1356
    
    >> applycform([.2 .3 .4],makecform('srgb2xyz'))
    
    ans =
    
    0.0617    0.0679    0.1024
    
    >> rgb2xyz([.2 .3 .4],'WhitePoint','D50')
    
    ans =
    
    0.0616    0.0679    0.1025
    

    Note the documentation for makecform suggests using the more recent rgb2xyz instead. As for your comment about reproducing the results using a matrix, note that the matrices are generally derived from / applied to linear data. If you want to reproduce the results you'll need to model the srgb gamma correction as well.