如何将RGB图像转换为CIELUV色彩空间?

时间:2019-05-15 07:54:45

标签: java rgb cieluv

如何将RGB图像转换为CIELUV颜色空间?有没有图书馆可以解决这个问题?

1 个答案:

答案 0 :(得分:1)

从这个page您可以想象这样的事情:

//sR, sG and sB (Standard RGB) input range = 0 ÷ 255
//X, Y and Z output refer to a D65/2° standard illuminant.

var_R = ( sR / 255 )
var_G = ( sG / 255 )
var_B = ( sB / 255 )

if ( var_R > 0.04045 ) var_R = ( ( var_R + 0.055 ) / 1.055 ) ^ 2.4
else                   var_R = var_R / 12.92
if ( var_G > 0.04045 ) var_G = ( ( var_G + 0.055 ) / 1.055 ) ^ 2.4
else                   var_G = var_G / 12.92
if ( var_B > 0.04045 ) var_B = ( ( var_B + 0.055 ) / 1.055 ) ^ 2.4
else                   var_B = var_B / 12.92

var_R = var_R * 100
var_G = var_G * 100
var_B = var_B * 100

X = var_R * 0.4124 + var_G * 0.3576 + var_B * 0.1805
Y = var_R * 0.2126 + var_G * 0.7152 + var_B * 0.0722
Z = var_R * 0.0193 + var_G * 0.1192 + var_B * 0.9505

要进入XYZ-space,然后从XYZ转到CIELUV:

//Reference-X, Y and Z refer to specific illuminants and observers.
//Common reference values are available below in this same page.

var_U = ( 4 * X ) / ( X + ( 15 * Y ) + ( 3 * Z ) )
var_V = ( 9 * Y ) / ( X + ( 15 * Y ) + ( 3 * Z ) )

var_Y = Y / 100
if ( var_Y > 0.008856 ) var_Y = var_Y ^ ( 1/3 )
else                    var_Y = ( 7.787 * var_Y ) + ( 16 / 116 )

ref_U = ( 4 * Reference-X ) / ( Reference-X + ( 15 * Reference-Y ) + ( 3 * Reference-Z ) )
ref_V = ( 9 * Reference-Y ) / ( Reference-X + ( 15 * Reference-Y ) + ( 3 * Reference-Z ) )

CIE-L* = ( 116 * var_Y ) - 16
CIE-u* = 13 * CIE-L* * ( var_U - ref_U )
CIE-v* = 13 * CIE-L* * ( var_V - ref_V )

再次从http://www.easyrgb.com/en/math.php复制过来,所以给他们一个视图。