Exemple #1
0
 public Color calculatePixel(Color c)
 {
     if (GrayScale.toGrayscale(c) < _treshold)
     {
         return(Color.Black);
     }
     else
     {
         return(Color.White);
     }
 }
 private void GrayscaleButton_Click(object sender, EventArgs e)
 {
     for (int i = 0; i < pictureBox1.Image.Width; i++)
     {
         for (int j = 0; j < pictureBox1.Image.Height; j++)
         {
             Color color    = picture.Bitmap.GetPixel(i, j);
             Color newColor = Color.FromArgb(GrayScale.toGrayscale(color), GrayScale.toGrayscale(color), GrayScale.toGrayscale(color));
             picture.Bitmap.SetPixel(i, j, newColor);
         }
     }
     pictureBox1.Refresh();
 }