def histogram(a, bins=10, range=None, weights=None, **kwargs):
 if isinstance(bins, six.string_types):
  a = np.asarray(a).ravel()
  if (weights is not None):
   raise NotImplementedError(u'weights are not yet supported for the enhanced histogram')
  if (range is not None):
   a = a[((a >= range[0]) & (a <= range[1]))]
  if (bins == u'blocks'):
   bins = bayesian_blocks(a)
  elif (bins == u'knuth'):
   (da, bins) = knuth_bin_width(a, True)
  elif (bins == u'scott'):
   (da, bins) = scott_bin_width(a, True)
  elif (bins == u'freedman'):
   (da, bins) = freedman_bin_width(a, True)
  else:
   raise ValueError(u"unrecognized bin code: '{}'".format(bins))
 return np.histogram(a, bins=bins, range=range, weights=weights, **kwargs)

def histogram ( a , bins = 10 , range = None , weights = None , ** kwargs ) : if isinstance ( bins , six . string_types ) : a = np . asarray ( a ) . ravel ( ) if ( weights is not None ) : raise NotImplementedError ( u'weights are not yet supported for the enhanced histogram' ) if ( range is not None ) : a = a [ ( ( a >= range [ 0 ] ) & ( a <= range [ 1 ] ) ) ] if ( bins == u'blocks' ) : bins = bayesian_blocks ( a ) elif ( bins == u'knuth' ) : ( da , bins ) = knuth_bin_width ( a , True ) elif ( bins == u'scott' ) : ( da , bins ) = scott_bin_width ( a , True ) elif ( bins == u'freedman' ) : ( da , bins ) = freedman_bin_width ( a , True ) else : raise ValueError ( u"unrecognized bin code: '{}'" . format ( bins ) ) return np . histogram ( a , bins = bins , range = range , weights = weights , ** kwargs )
calculates the histogram of the given image .