Today I stumbled across this (for me) weird thing, namely when I run this code
m.convertTo(tmp_mat, CV_32FC3, 1./255);
cvtColor(tmp_mat, tmp_mat, CV_RGB2XYZ, 3);
split(tmp_mat, xyz_channels);
y_channel = xyz_channels[1].clone();
int i,j;
uint8_t* p = y_channel.data;
for( i = 0; i < y_channel.rows; ++i)
{
for ( j = 0; j < y_channel.cols; ++j)
{
std::cout << y_channel.at<double>(i,j) << std::endl;
std::cout << saturate_cast<double>(p[i*y_channel.cols + j]) << std::endl;
}
}
this is the output I get
0.00683212
123
0.00683212
63
0.00683212
254
0.00683212
251
0.00683212
123
0.00683212
63
So now I am confused - shouldn't it be same?