将RGB图像转换为灰度

我是编程新手。 我是一名大学生。 是否可以使用visual studio将RGB图像转换为使用C#的灰度图像?

有一个特定的文件夹,包括RGB jpeg图像,每天它也有新的jpg文件。 我需要制作一个exe文件,将它们转换为灰度。

我是否必须为此工作安装新库,或者VS2013的标准库是否足够?

标准库就足够了。

我曾经使用过这段代码:

 public static Bitmap GrauwertBild(Bitmap input) { Bitmap greyscale = new Bitmap(input.Width, input.Height); for (int x = 0; x < input.Width; x++) { for (int y = 0; y < input.Height; y++) { Color pixelColor = input.GetPixel(x, y); // 0.3 · r + 0.59 · g + 0.11 · b int grey = (int)(pixelColor.R * 0.3 + pixelColor.G * 0.59 + pixelColor.B * 0.11); greyscale.SetPixel(x, y, Color.FromArgb(pixelColor.A, grey , grey , grey )); } } return greyscale; }