code: def _segMaskB2I(mask_path, save_path):
      img = np.asarray(Image.open(mask_path))
      mask = np.zeros_like(img)
      results = cv2.findContours(
          img, cv2.RETR_CCOMP, cv2.CHAIN_APPROX_NONE
      )
      cv2_v = cv2.__version__.split(".")[0]
      contours = results[1] if cv2_v == "3" else results[0]  # 边界
      hierarchys = results[2] if cv2_v == "3" else results[1]  # 隶属信息
      areas = {}  # 面积
      for i in range(len(contours)):
          areas[i] = cv2.contourArea(contours[i])
      sorted(
          areas.items(), key=lambda kv: (kv[1], kv[0]), reverse=True
      )  # 面积升序
      # 开始填充
      color = 1
      for idx in areas.keys():
          contour = contours[idx]
          hierarchy = hierarchys[0][idx]
          # print(hierarchy)
          if hierarchy[-1] == -1:  # 输入子轮廓
              cv2.fillPoly(mask, [contour], color)
              color += 1
          else:
              cv2.fillPoly(mask, [contour], 0)
      # 显示
      # cv2.drawContours(mask, contours, -1, (125,125,125), 1)
      # cv2.imshow('src',mask)
      # cv2.waitKey()
      _savePalette(mask, save_path)
  
file_path: PaddleSeg/EISeg/tool/semantic2instance.py
imports: import os
  import os.path
  import argparse
  from tqdm import tqdm
  import numpy
  import cv2
  from PIL import Image
label_desc: Use image node_id 2 for calling a global function with example usage: _segMaskB2I(mask_path, save_path) without return types