title: How to find the first and last non-zero values for column and row in an image?
body: <p>I'm having trouble, because I have this image, what I want to do is just work with the pixels that aren't black. But I have to find the first and last nonzero values to define the boundaries were I will work, the problem is that I can find the first nonzero values(rowandcolumn), but in  the last for the column appears the value 1799,and my image is 499x631x3 uint8 , and it should be 533. What is the problem??</p>
  
  <p>My code below:</p>
  
  <pre><code>%Find where the image begins and starts
  [r_min, c_min]=find(movingRegistered(:),1,'first');
  [r_max, c_max]=find(movingRegistered(:,:),1,'last');
  </code></pre>
  
  <p>Image link <a href="https://www.dropbox.com/s/6fkwi3xbicwzonz/registered%20image.png?dl=0" rel="nofollow">https://www.dropbox.com/s/6fkwi3xbicwzonz/registered%20image.png?dl=0</a></p>