2016-03-06 62 views
0

https://rosettacode.org/wiki/Grayscale_image#C.23R,G和B係數的這些值來自哪裏?

Bitmap tImage = new Bitmap("spectrum.bmp"); 

for (int x = 0; x < tImage.Width; x++) 
{ 
    for (int y = 0; y < tImage.Height; y++) 
    { 
     Color tCol = tImage.GetPixel(x, y); 

     // L = 0.2126·R + 0.7152·G + 0.0722·B 
     double L = 0.2126 * tCol.R + 0.7152 * tCol.G + 0.0722 * tCol.B; 
     tImage.SetPixel(x, y, Color.FromArgb(Convert.ToInt32(L), 
Convert.ToInt32(L), Convert.ToInt32(L))); 
    } 
} 

// Save 
tImage.Save("spectrum2.bmp"); 

我們從哪裏找到這些// L = 0.2126·R + 0.7152·G + 0.0722·B值?

+0

[維基百科上的灰度(https://開頭的連接。 wikipedia.org/wiki/Grayscale) – TaW

回答