private Bitmap ToG(string file)
{
using (Bitmap o = new Bitmap(file))
{
Bitmap g = new Bitmap(o.Width, o.Height);
for (int i = ; i < o.Width; i++)
{
for (int j = ; j < o.Height; j++)
{
Color c = o.GetPixel(i, j);
//灰度加权平均法公式
int rgb = (int)(c.R * 0.299 + c.G * 0.587 + c.B * 0.114);
g.SetPixel(i, j, Color.FromArgb(rgb, rgb, rgb));
}
}
return g;
}
}