# Revision history [back]

### cvtcolor RGB to XYZ

In modules/imgproc/src/color.cpp, line 678:

static const int coeffs0[] =
{
1689,    1465,    739,
871,     2929,    296,
79,      488,     3892
};


Could anybody tell me where this matrix comes from?

I guess it was somehow computed from

and

but how and why?

### cvtcolor RGB to XYZ

In modules/imgproc/src/color.cpp, line 678:

static const int coeffs0[] =
{
1689,    1465,    739,
871,     2929,    296,
79,      488,     3892
};


Could anybody tell me where this matrix comes from?

I guess it was somehow computed from

and

but how and why?

Update (posted this as an answer but not allowed because I'm a new member):

OK I hope somebody can have a better answer.

It is actually

(in the code, 16 is defined as the shift)

This is for defining cv::RGB2XYZ_i that will be used in the case the input data are integer ('i' for integer).

I guess the main reason for such a conversion is PRECISION (for cv::RGB2XYZ_f, this conversion is not needed, please refer to the source code for details).

### cvtcolor RGB to XYZ

In modules/imgproc/src/color.cpp, line 678:

static const int coeffs0[] =
{
1689,    1465,    739,
871,     2929,    296,
79,      488,     3892
};


Could anybody tell me where this matrix comes from?

I guess it was somehow computed from

and

but how and why?

Update (posted this as an answer but not allowed because I'm a new member):

OK I hope somebody can have a better answer.

It is actually

(in (correction: 2^12 instead of 2^16, sorry. In the code, 16 16 is defined as the shift)

This is for defining cv::RGB2XYZ_i that will be used in the case the input data are integer ('i' for integer).

I guess the main reason for such a conversion is PRECISION (for cv::RGB2XYZ_f, this conversion is not needed, please refer to the source code for details).

### cvtcolor RGB to XYZ

In modules/imgproc/src/color.cpp, line 678:

static const int coeffs0[] =
{
1689,    1465,    739,
871,     2929,    296,
79,      488,     3892
};


Could anybody tell me where this matrix comes from?

I guess it was somehow computed from

and

but how and why?

Update (posted this as an answer but not allowed because I'm a new member):

OK I hope somebody can have a better answer.

It is actually

(correction: 2^12 instead of 2^16, sorry. In the code, 1612 is defined as the shift)

This is for defining cv::RGB2XYZ_i that will be used in the case the input data are integer ('i' for integer).

I guess the main reason for such a conversion is PRECISION (for cv::RGB2XYZ_f, this conversion is not needed, please refer to the source code for details).

 5 retagged sturkmen 6772 ●3 ●48 ●79 https://github.com/stu...

### cvtcolor RGB to XYZ

In modules/imgproc/src/color.cpp, line 678:

static const int coeffs0[] =
{
1689,    1465,    739,
871,     2929,    296,
79,      488,     3892
};


Could anybody tell me where this matrix comes from?

I guess it was somehow computed from

and

but how and why?