code: def equalize_func(img):
      """
      same output as PIL.ImageOps.equalize
      PIL's implementation is different from cv2.equalize
      """
      n_bins = 256
  
      def tune_channel(ch):
          hist = cv2.calcHist([ch], [0], None, [n_bins], [0, n_bins])
          non_zero_hist = hist[hist != 0].reshape(-1)
          step = np.sum(non_zero_hist[:-1]) // (n_bins - 1)
          if step == 0:
              return ch
          n = np.empty_like(hist)
          n[0] = step // 2
          n[1:] = hist[:-1]
          table = (np.cumsum(n) // step).clip(0, 255).astype(np.uint8)
          return table[ch]
  
      channels = [tune_channel(ch) for ch in cv2.split(img)]
      out = cv2.merge(channels)
      return out
  
imports: import cv2
  import numpy
label_desc: Use image node_id 3 for calling a global function with example usage: equalize_func(img) and returns: out, table, ch