code: def segment_region_score(
      watershed_param, region_score, word_image, pseudo_vis_opt
  ):
      region_score = np.float32(region_score) / 255
      fore = np.uint8(region_score > 0.75)
      back = np.uint8(region_score < 0.05)
      unknown = 1 - (fore + back)
      ret, markers = cv2.connectedComponents(fore)
      markers += 1
      markers[unknown == 1] = 0
  
      labels = watershed(-region_score, markers)
      boxes = []
      for label in range(2, ret + 1):
          y, x = np.where(labels == label)
          x_max = x.max()
          y_max = y.max()
          x_min = x.min()
          y_min = y.min()
          box = [
              [x_min, y_min],
              [x_max, y_min],
              [x_max, y_max],
              [x_min, y_max],
          ]
          box = np.array(box)
          box *= 2
          boxes.append(box)
      return np.array(boxes, dtype=np.float32)
  
imports: import cv2
  import numpy
  from skimage.segmentation import watershed
label_desc: Use image node_id 1 for calling a global function with example usage: segment_region_score(watershed_param, region_score, word_image, pseudo_vis_opt) and returns: np