Problems with using a rough greyscale algorithm?

前端 未结 7 2100
生来不讨喜
生来不讨喜 2021-02-06 20:43

So I\'m designing a few programs for editing photos in python using PIL and one of them was converting an image to greyscale (I\'m avoiding the use of

7条回答
  •  梦毁少年i
    2021-02-06 20:50

    You can use any conversion equation, scale, linearity. The one you found:

    I = 0.299 R + 0.587 G + 0.114 B
    

    is based on average human eye "average" primary color (R,G,B) perception sensitivity (at least for the time period and population/HW it was created on; bear in mind those standards were created before LED,TFT, etc. screens).

    There are several problems you are fighting against:

    1. our eyes are not the same

      All humans do not perceive color the same way. There are major discrepancies between genders and smaller also between regions; even generation and age play a role. So even an average should be handled as "average".

      We have different sensitivity to intensity of light across the visible spectrum. The most sensitive color is green (hence the highest weight on it). But the XYZ curve peaks can be at different wavelengths for different people (like me I got them shifted a bit causing difference in recognition of certain wavelengths like some shades of Aqua - some see them as green some as blue even if none of them have any color blindness disabilities or whatever).

    2. monitors do not use the same wavelengths nor spectral dispersion

      So if you take 2 different monitors, they might use slightly different wavelengths for R, G, B or even different widths of the spectral filter (just use a spectroscope and see). Yes they should be "normalized" by the HW but that is not the same as using normalized wavelengths. It is similar to problems using RGB vs. White Noise spectrum light sources.

    3. monitor linearity

      Humans do not see on a linear scale: we are usually logarithmic/exponential (depends how you look at it) so yes we can normalize that with HW (or even SW) but the problem is if we linearize for one human then means we damage it for another.

    If you take all this together you can either use averages ... or special (and expensive) equipment to measure/normalize against some standard or against a calibrated person (depends on the industry).

    But that is too much to handle in home conditions so leave all that for industry and use the weights for "average" like most of the world... Luckily our brain can handle it as you cannot see the difference unless you start comparing both images side by side or in an animation :). So I (would) do:

    I = 0.299 R + 0.587 G + 0.114 B
    R = I
    G = I
    B = I
    

提交回复
热议问题