Conversion to gray level


To perform digital image correlations, I use 2 gray-level images stored in that form (pseudo code):

uint16_t image[dimx][dimy];

I use LibRaw in two ways: (1) self basic demosaicing by computing the mean over 4 raw pixels, or (2) let LibRaw perform a sophisticated demosaicing (with dcraw_process) and convert the resulting rgbg2 to gray levels.

My question is about this conversion (I recall here that my objective is not to obtain nice photographs but to perform quantitative image analysis).
Can I ignore the g2 value by making something like (0.299*r + 0.587*g + 0.114*b)?
Should I instead use 0.25*(r+g+b+g2)?

In fact I'm a little lost with the RGBG2 since it look like a piece of mosaic but it is issued from a post-processing operation. So I do not understand why a simple RGB (or something else) is not used!
I would please appreciate some clarification on this point.

I thank you in advance for your help.


For unprocessed (not

For unprocessed (not demosaiced) image you may ignore G2 or average (G+G2)/2.
Processed image is RGB in most cases, just ignore 4th component.

-- Alex Tutubalin