Could anyone tell me more about the raw buffer's content? I am now trying to replace all the green or some other color that is near green to red. I am using the function of rawop_get_pixels_rgbg and rawop_set_pixels_rgbg(same content, just change the API to fit for C). I am using the filter of ((g1>800||g2>800)&&r<600&&b<600), but it seems it can only detect a really small amount of green object in the picture. Is there any fomular or some reference material to show the relation between actual color the rgbg code(for example, change rgbg into standard RGB)?
The "rgbg" function just work on a four adjacent pixels like
R G
G B
and gives you the correct pixels for whatever you bayer pattern is. If you want RGB color like you would get in a jpeg, you need to correct for the filters different responses. The color matrix should help you do this in theory, but it may or may not be accurate for any given port. The dng specification has some information.
Depending your needs, you may not need full color calibration. If you just want to find out if a part of the scene is strongly green, some ad-hoc coefficients might be enough. The drtest.lua script can help you see the relative responses.
I'm not sure what you mean by "an only detect a really small amount of green object in the picture"