code: def get_bg(background, img_shape):
      bg = np.zeros(img_shape)
      if background == "r":
          bg[:, :, 2] = 255
      elif background is None or background == "g":
          bg[:, :, 1] = 255
      elif background == "b":
          bg[:, :, 0] = 255
      elif background == "w":
          bg[:, :, :] = 255
  
      elif not os.path.exists(background):
          raise Exception(
              "The --background is not existed: {}".format(background)
          )
      else:
          bg = cv2.imread(background)
          bg = cv2.resize(bg, (img_shape[1], img_shape[0]))
      return bg
  
file_path: PaddleSeg/Matting/tools/bg_replace.py
imports: import argparse
  import os
  import sys
  import cv2
  import numpy
  import paddle
  import paddleseg
  from paddleseg.cvlibs import manager
  from paddleseg.utils import get_sys_env, logger
  import ppmatting
  from ppmatting.core import predict
  from ppmatting.utils import get_image_list, estimate_foreground_ml, Config, MatBuilder
label_desc: Use image node_id 3 for calling a global function with example usage: get_bg(background, img_shape) and returns: bg