code: def get_boundaries(instances_masks, boundaries_width=1):
      boundaries = np.zeros(
          (instances_masks.shape[0], instances_masks.shape[1]),
          dtype=np.bool,
      )
  
      for obj_id in np.unique(instances_masks.flatten()):
          if obj_id == 0:
              continue
  
          obj_mask = instances_masks == obj_id
          kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (3, 3))
          inner_mask = cv2.erode(
              obj_mask.astype(np.uint8),
              kernel,
              iterations=boundaries_width,
          ).astype(np.bool)
  
          obj_boundary = np.logical_xor(
              obj_mask, np.logical_and(inner_mask, obj_mask)
          )
          boundaries = np.logical_or(boundaries, obj_boundary)
      return boundaries
  
file_path: PaddleSeg/EISeg/eiseg/util/vis.py
imports: from functools import lru_cache
  import cv2
  import numpy
label_desc: Use image node_id 9 for calling a global function with example usage: get_boundaries(instances_masks, boundaries_width) and returns: boundaries