code: def get_global_threshold(threshold_method, image, mask = None, **kwargs):
      
      if mask is not None and not np.any(mask):
          return 1
      
      if threshold_method == TM_OTSU:
          fn = get_otsu_threshold
      elif threshold_method == TM_MOG:
          fn = get_mog_threshold
      elif threshold_method == TM_BACKGROUND:
          fn = get_background_threshold
      elif threshold_method == TM_ROBUST_BACKGROUND:
          fn = get_robust_background_threshold
      elif threshold_method == TM_RIDLER_CALVARD:
          fn = get_ridler_calvard_threshold
      elif threshold_method == TM_KAPUR:
          fn = get_kapur_threshold
      elif threshold_method == TM_MCT:
          fn = get_maximum_correlation_threshold
      else:
          raise NotImplementedError("%s algorithm not implemented"%(threshold_method))
      kwargs = dict([(k, v) for k, v in kwargs.items()
                     if k in fn.args])
      return fn(image, mask, **kwargs)
docs: Compute a single threshold over the whole image