I tried out some of common greyscale conversion formulas but none of them worked just like the test result above.
I think it uses freeImage internally, but I don’t know how to see the implementation part of the greyscale method which is “FreeImage_ConvertToGreyscale”.
Can anyone help me out finding the formula? Thanks.
Are you sure about those RGB values? In the source of Freeimage it says:
Luminance is calculated from the sRGB model using a D65 white point, using the Rec.709 formula
L = ( 0.2126 * r ) + ( 0.7152 * g ) + ( 0.0722 * b )
And in the implementation:
#define LUMA_REC709(r, g, b) (0.2126F * r + 0.7152F * g + 0.0722F * b)
#define GREY(r, g, b) (BYTE)(LUMA_REC709(r, g, b) + 0.5F)
So the formula should be the above one for Luminance + 0.5, but this returns different values from the ones you’ve measured. Did you take those measurements in OF?
Yes, I did. I got those measurements from loading a jpg image.
And here’s an example code to measure it without loading an image and I get the same results.