docs: def automode(data):
      '''Tries to guess if the image contains dark objects on a bright background (1)
  or if the image contains bright objects on a dark background (-1),
  or if it contains both dark and bright objects on a gray background (0).'''
  
      
      
      pct=prcntiles(np.array(data),[1,20,80,99])
      
      upper=pct[3]-pct[2]
      mid=pct[2]-pct[1]
      lower=pct[1]-pct[0]
  
      ##print 'upper = '+str(upper)
      ##print 'mid = '+str(mid)
      ##print 'lower = '+str(lower)
  
      #upper objects
      if upper>mid:
          uo=1
      else:
          uo=0
      ##print 'uo = '+str(uo)
  
      #lower objects
      if lower>mid:
          lo=1
      else:
          lo=0
      ##print 'lo = '+str(lo)
      
      if uo==1:
          if lo==1:
              mode=0
              #both upper and lower objects
          else:
              mode=-1
              #only upper objects
      else:
          if lo==1:
              mode=1
              #only lower objects
          else:
              mode=0
              #no objects at all
              
      return mode