Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
16
Task/Grayscale-image/C-sharp/grayscale-image.cs
Normal file
16
Task/Grayscale-image/C-sharp/grayscale-image.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
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");
|
||||
Loading…
Add table
Add a link
Reference in a new issue