I'm new on programming. I'm a student in a univesity. Is it possible to use visual studio for converting RGB images to grayscale with C#?
There is a specific folder that includes RGB jpeg images and every day it has new jpg files too. I need to make an exe file for converting them to grayscale.
Do I have to install new libraries for this work or are standard libraries of VS2013 enough for this?
The standard libraries are enough.
I once used this code:
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;
}