title: Convert gray image to binary image (0 1 image) in C#?
body: <p>I have some code lines. I just want to convert a gray-scale image to a binary image. It look so simple but i don't understand where is wrong!
  Can you tell me where is it wrong. 
  Here is it:</p>
  
  <pre><code>private void convert()
          {
              try
              {
                  OpenFileDialog op = new OpenFileDialog();
                  op.InitialDirectory = "D:/";
                  op.Filter = "All Files|*.*|JPEGs|*.jpg|Bitmaps|*.bmp|GIFs|*.gif";
                  op.FilterIndex = 1;
  
                  if (op.ShowDialog() == DialogResult.OK)
                  {
                      pictureBox3.Image = Image.FromFile(op.FileName);
                      pictureBox3.SizeMode = PictureBoxSizeMode.StretchImage;
                      pictureBox3.BorderStyle = BorderStyle.Fixed3D;
  
                      Bitmap img = new Bitmap(op.FileName);
                      int width = img.Width;
                      int height = img.Height;
                      string t = "";
                      for (int i = 0; i &lt; width; i++)
                      {
                          for (int j = 0; j &lt; height; j++)
                          {
                              if (img.GetPixel(j, i).A &gt; 100 &amp;&amp; img.GetPixel(j, i).B &gt; 100 &amp;&amp; img.GetPixel(j, i).G &gt; 100 &amp;&amp; img.GetPixel(j, i).R &gt; 100)
  
                              {
                                  t = t + "0";
                              }
                              else
                              {
                                  t = t + "1";
                              }
                          }
                          t = t + "\r\n";
                      }
                      textBox1.Text = t;
                  }
              }
              catch { };
          }
  </code></pre>
  
  <p>Thanks all!</p>