code: def find_components(im, max_components=16):
      """Dilate the image until there are just a few connected components.
      Returns contours for these components."""
      kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (10, 10))
      dilation = dilate(im, kernel, 6)
  
      count = 21
      n = 0
      sigma = 0.000
  
      while count > max_components:
          n += 1
          sigma += 0.005
          result = cv2.findContours(
              dilation, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE
          )
          if len(result) == 3:
              _, contours, hierarchy = result
          elif len(result) == 2:
              contours, hierarchy = result
          possible = find_likely_rectangles(contours, sigma)
          count = len(possible)
  
      return (dilation, possible, n)
  
imports: import os
  import traceback
  import sys
  import cv2
  import numpy
  from PIL import Image
  from scipy.ndimage.filters import rank_filter
  import pytesseract
label_desc: Use image node_id 4 for calling a global function with example usage: find_components(im, max_components) and returns: dilation,  possible,  n