title: How to extract non zero values from an image?
body: <p>i want to extract lines from a text document. I can accomplish this by summing its columns and produce a 1 dimensional vector (This will be the horizontal projection of the image). This is the image
  <img src="https://i.stack.imgur.com/NnCNK.jpg" alt="enter image description here"></p>
  
  <pre><code>img = imcomplement(rgb2gray(imread('french.jpg')));
  lines = sum(img, 2);
  plot(lines);
  </code></pre>
  
  <p>If I plot this I can see that the zero values show the blank spaces and the peaks depict the lines. Here is the plot</p>
  
  <p><img src="https://i.stack.imgur.com/3MRfM.jpg" alt="enter image description here"> </p>
  
  <p>So looking at the plot (and the array) I can tell that the third line is from array index <code>129:184</code>. So to extract it I did this</p>
  
  <pre><code>test = lines(129:184);
  </code></pre>
  
  <p>It does not seem to work as if I do <code>imshow(test)</code> or <code>imshow(test, [])</code> It gives the following result. Not exactly the third line.</p>
  
  <p><img src="https://i.stack.imgur.com/ogWgW.jpg" alt="enter image description here"></p>
  
  <p>What am I doing wrong here?</p>