title: Matlab convert image from gray to binary
body: <p>İn Matlab, I want to threshold a grayscale image to convert it to a black &amp; white image:</p>
  
  <pre><code>for k=1:Y
    for i=1:X
      if gray(i,k)&gt;T
        gray(i,k)=1;
      else
        gray(i,k)=0;
      end
    end
  end
  </code></pre>
  
  <p>What do you think should be the value of T?</p>