2

How I can convert RGB image to CIELUV color space? Does there any library exists solve this problem?

bvl
  • 161
  • 2
  • 12
  • You can try [CIELuv](http://gicentre.org/utils/reference/org/gicentre/utils/colour/CIELuv.html) from [gicentreutils](https://github.com/gicentre/gicentreutils) P.S. Digital Image Processing An Algorithmic Introduction Using Java Wilhelm Burger, Mark J. Burge ISBN 978-1-4471-6684-9 – Victor Gubin May 15 '19 at 08:05

1 Answers1

2

From this page you could imagine something like this:

//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

To get to XYZ-space and then, to go from XYZ to 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 )

Again just copied from http://www.easyrgb.com/en/math.php so go give them a view.

Adam
  • 2,845
  • 2
  • 32
  • 46
  • 1
    If I want to convert sRGB image to CIELUV, I need to take reference-X,Y,Z values as D65/2°? – bvl May 15 '19 at 08:42
  • @bvl Correct, use the D65 2° observer whitepoint reference for the reference XYZ values. X = 95.047, Y = 100, Z =108.883 – Myndex Nov 05 '21 at 02:56