Estimate RGB image color temperature
* Read in an RGB image, assuming it is sRGB display ready * Convert them to XYZ * Calculate the mean chromaticity of the top 10 percent of the Y values * Calculate the chromaticity of a white surface under different color temperature blackbody radiators * Find a close match and return the color temperature
See also sceneFromFile
Contents
Create a scene with a low color temperature
scene = sceneCreate('macbeth tungsten'); oi = oiCreate; oi = oiCompute(oi,scene); sensor = sensorCreate; sensor = sensorSet(sensor,'fov',sceneGet(scene,'fov'),oi); sensor = sensorCompute(sensor,oi); ip = ipCreate; ip = ipCompute(ip,sensor); % ipWindow(ip); rgb = ipGet(ip,'srgb'); cTemp = srgb2colortemp(rgb); disp(cTemp)
3500
Not quite perfect for the MCC because, we think
the white isn't really white
scene = sceneCreate('macbeth d65'); oi = oiCreate; oi = oiCompute(oi,scene); sensor = sensorCreate; sensor = sensorSet(sensor,'fov',sceneGet(scene,'fov'),oi); sensor = sensorCompute(sensor,oi); ip = ipCreate; ip = ipCompute(ip,sensor); % ipWindow(ip); rgb = ipGet(ip,'srgb'); [cTemp,cTable] = srgb2colortemp(rgb); disp(cTemp) disp(cTable(:,1)) disp(cTable(:,2:3))
5500
2500
3000
3500
4000
4500
5000
5500
6000
6500
7000
7500
8000
8500
9000
9500
10000
10500
0.4766 0.4140
0.4367 0.4044
0.4051 0.3911
0.3803 0.3771
0.3607 0.3639
0.3451 0.3520
0.3325 0.3415
0.3221 0.3322
0.3136 0.3241
0.3065 0.3171
0.3004 0.3108
0.2953 0.3054
0.2909 0.3005
0.2871 0.2962
0.2837 0.2924
0.2808 0.2889
0.2782 0.2858