title: How can I binarize images with text? [MATLAB]
body: <p>I have a problem with a binarization method.
  I have images with text, which I want to binarize. 
  I want the text ends up being white, but there are images with the text darker than the background and there are images with text less dark than the background.
  <a href="https://i.stack.imgur.com/dZm0V.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dZm0V.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/xiPfF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xiPfF.png" alt="enter image description here"></a></p>
  
  <p>I want to binarize images like these, but I want the text in white color in the binarized images.</p>
  
  <p>By the way, I am binarizing images with this code. This code is good for images with text darker than the background but it isn't good for text less darker than the background. I think I need a method to know if the text is more or less dark than the background for to invert or no invert the binarization.</p>
  
  <pre><code>        umb = graythresh(originalImage);
          binaryImage =(~im2bw(originalImage,umb));
  </code></pre>
  
  <p>How can I do it?</p>
  
  <p>Thanks a lot for the help</p>