Talk:Grayscale image

From Rosetta Code

Linear color space

If I am not wrong, the equation L = 0.2126·R + 0.7152·G + 0.0722·B only works correctly in linear color space. Most images, however, are stored in sRGB color space. If you want to do the conversion correctly for a real world image, you should first convert it into linear color space.

But for simplicity, I guess, we could assume that the image is already in linear color space (even if it actually would require at least 16 bit color depth instead of 8 bit). --PauliKL 17:00, 15 January 2009 (UTC)

The "parent" task is silent about the color model. If you want to fix it in this way or another, I think, you should better start there.
Surely we could define some additional tasks dealing with different color models and conversions between them. I am not sure that this would meet much interest.
Thinking further in this direction, there are so many areas in image processing / computer graphics, that I seriously doubt if RC would ever able to represent more than just a fraction of. Especially because most of them quickly grow out of "boy" format. I wished to add image segmenting tasks, by region growing, by pyramid etc, but then I realized that already this would be far over the top... --Dmitry-kazakov 18:33, 15 January 2009 (UTC)
Color models are not relevant in the parent task. Creating a storage for image and plotting pixels do not care about color models. Color models are needed when doing conversions, such as RGB to grayscale conversion.
The point is that the CIE conversion function mentioned requires linear color mode. If linear color model is not used, you could use just about any weighting factors for R, G and B, and it does not help to use so many decimal digits. A common function used in sRGB color space is L = 0.3*R + 0.59*G + 0.11*B . When this is applied to and sRGB image, the results are closer to CIE conversion than when you use the CIE function in sRGB color space. I just thought that this should be mentioned, in case someone is planning to use the code examples given here in a real application.
Another commonly overlooked fact is that most image processing functions such as resizing only work correctly in linear color space. But that is another story.
--PauliKL 16:00, 16 January 2009 (UTC)