title: How to get python to recognize a scale bar and set the dimensions of the image
body: <p>I have simple script that loads in an image that has a vertical and horizontal scale bar in the lower left corner (vertical scale is first column of pixels) and horizontal scale bar is a line on the first row of pixels.</p>
  <p>My script then looks at that and I set the dimensions however half the time I export images it works, the other half of the time I get the error &quot;float division by zero&quot; because I think it does not see the first row or somehow adding an extra row.</p>
  <p>Any help would be MORE than appreciated! Below is an example of the code for the vertical scale bar. I do the same steps for the horizontal scale bar</p>
  <pre><code>s = mpimg.imread(r'C:\Users\XDF\Desktop\ScaleTest.tif')
  vbar_len = 10.0 # length of vertical scale bar in meters
  vscale = vbar_len/len(s[:,0,0][s[:,0,0]==0]) # vertical scale in meters / pixel
  print (v_scale)
  </code></pre>
  <p><a href="https://i.stack.imgur.com/FatRB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FatRB.png" alt="Example image and you can see the scale bars on the lower left corner" /></a></p>