/// <summary> /// 去杂色,转换为黑白图片 /// </summary> /// <param name="img"></param> public static void Binarization(Bitmap img, int thresholdValue) { for (int x = 0; x < img.Width; x++) { for (int y = 0; y < img.Height; y++) { Color c = img.GetPixel(x, y); if (c.R >= thresholdValue) img.SetPixel(x, y, Color.FromArgb(255, 255, 255)); else img.SetPixel(x, y, Color.FromArgb(0, 0, 0)); } } }