Gray = (Red + Green + Blue) / 3
Gray = (Red * 0.3 + Green * 0.59 + Blue * 0.11)
上半部分算法1,下半部分算法2
( Math.max(Red, Green, Blue) + Math.min(Red, Green, Blue) ) / 2
Math.max(Red, Green, Blue)
Math.min(Red, Green, Blue)
Gray = Red
Gray = Green
Gray = Blue
ConversionFactor = 255 / (NumberOfShades - 1)
AverageValue = (Red + Green + Blue) / 3
Gray = Math.round((AverageValue / ConversionFactor) + 0.5) * ConversionFactor
4 shades
16 shades