code: def rc(img, ignore_zeros=False):
      """
      T = rc(img, ignore_zeros=False)
  
      Calculate a threshold according to the Riddler-Calvard method.
  
      Example::
  
          import mahotas as mh
          import mahotas.demos
  
          im = mahotas.demos.nuclear_image()
          # im is stored as RGB, let's convert to single 2D format:
          im = im.max(2)
  
          #Now, we compute a threshold:
          t = mh.rc(im)
  
          # finally, we use the value to form a binary image:
          bin = (im > t)
  
      Parameters
      ----------
      img : ndarray
          Image of any type
      ignore_zeros : boolean, optional
          Whether to ignore zero valued pixels (default: False)
  
      Returns
      -------
      T : float
          threshold
      """
      hist = fullhistogram(img)
      if ignore_zeros:
          if hist[0] == img.size:
              return 0
          hist[0] = 0
      N = hist.size
  
      # Precompute most of what we need:
      first_moment = np.cumsum(np.arange(N) * hist)
      cumsum = np.cumsum(hist)
  
      r_first_moment = np.flipud(
          np.cumsum(np.flipud(np.arange(N) * hist))
      )
      r_cumsum = np.flipud(np.cumsum(np.flipud(hist)))
  
      maxt = N - 1
      while hist[maxt] == 0:
          maxt -= 1
  
      res = maxt
      t = 0
      while t < min(maxt, res):
          if cumsum[t] and r_cumsum[t + 1]:
              res = (
                  first_moment[t] / cumsum[t]
                  + r_first_moment[t + 1] / r_cumsum[t + 1]
              ) / 2
          t += 1
      return res
  
file_path: mahotas/mahotas/thresholding.py
imports: from __future__ import division
  import numpy
  from .histogram import fullhistogram
  from .None import _histogram
  from .internal import _verify_is_integer_type
label_desc: Use image node_id 2 for calling a global function with example usage: rc(img, ignore_zeros) and returns: res, int