Add new comment

What exactly is pre_mul in libraw_colordata_t?

Hi,

I am new to raw image processing, and was just playing LibRaw for a couple of weeks. I apologize if this question has been asked before. So, I was trying to read a .CR2 file. In my first version, the image was very green, and I found that it was because I didn't multiply pixels with pre_mul. With a bit of code tracing, I found that pre_mul is calculated (in my case, lossless jpeg decoder) in cam_xyz_coeff() in utils_dcraw.cpp as follow:

for (num = j = 0; j < 3; j++)
num += cam_rgb[i][j];
if (num > 0.00001)
{
for (j = 0; j < 3; j++)
cam_rgb[i][j] /= num;
pre_mul[i] = 1 / num;
}

According to the doc, pre_mul should be the white balance coefficient of daylight, but according to the code, it's more like a factor used in cam to rgb color space conversion? So, what exactly is it? And how do the caller of API suppose to do with that? Should we just always multiply it to each raw pixel read from the raw image?

Forums: