class_docstr: Pass in a dataset that conforms to the format.
      matting_dataset/
      |--bg/
      |
      |--train/
      |  |--fg/
      |  |--alpha/
      |
      |--val/
      |  |--fg/
      |  |--alpha/
      |  |--trimap/ (if existing)
      |
      |--train.txt
      |
      |--val.txt
  See README.md for more information of dataset.
  
  Args:
      dataset_root(str): The root path of dataset.
      transforms(list):  Transforms for image.
      mode (str, optional): which part of dataset to use. it is one of ('train', 'val', 'trainval'). Default: 'train'.
      train_file (str|list, optional): File list is used to train. It should be `foreground_image.png background_image.png`
          or `foreground_image.png`. It shold be provided if mode equal to 'train'. Default: None.
      val_file (str|list, optional): File list is used to evaluation. It should be `foreground_image.png background_image.png`
          or `foreground_image.png` or ``foreground_image.png background_image.png trimap_image.png`.
          It shold be provided if mode equal to 'val'. Default: None.
      get_trimap (bool, optional): Whether to get triamp. Default: True.
      separator (str, optional): The separator of train_file or val_file. If file name contains ' ', '|' may be perfect. Default: ' '.
      key_del (tuple|list, optional): The key which is not need will be delete to accellect data reader. Default: None.
      if_rssn (bool, optional): Whether to use RSSN while Compositing image. Including denoise and blur. Default: False.
class_docstr_tok: ["Pass","in","a","dataset","that","conforms","to","the","format",".","matting_dataset\/","|","--","bg\/","|","|","--","train\/","|","|","--","fg\/","|","|","--","alpha\/","|","|","--","val\/","|","|","--","fg\/","|","|","--","alpha\/","|","|","--","trimap\/","(","if","existing",")","|","|","--","train.txt","|","|","--","val.txt","See","README.md","for","more","information","of","dataset",".","Args",":","dataset_root","(","str",")",":","The","root","path","of","dataset",".","transforms","(","list",")",":","Transforms","for","image",".","mode","(","str",",","optional",")",":","which","part","of","dataset","to","use",".","it","is","one","of","(","'train","'",",","'val","'",",","'trainval","'",")",".","Default",":","'train","'",".","train_file","(","str|list",",","optional",")",":","File","list","is","used","to","train",".","It","should","be","`","foreground_image.png","background_image.png","`","or","`","foreground_image.png","`",".","It","shold","be","provided","if","mode","equal","to","'train","'",".","Default",":","None",".","val_file","(","str|list",",","optional",")",":","File","list","is","used","to","evaluation",".","It","should","be","`","foreground_image.png","background_image.png","`","or","`","foreground_image.png","`","or","``","foreground_image.png","background_image.png","trimap_image.png","`",".","It","shold","be","provided","if","mode","equal","to","'val","'",".","Default",":","None",".","get_trimap","(","bool",",","optional",")",":","Whether","to","get","triamp",".","Default",":","True",".","separator","(","str",",","optional",")",":","The","separator","of","train_file","or","val_file",".","If","file","name","contains","'","'",",","'|","'","may","be","perfect",".","Default",":","'","'",".","key_del","(","tuple|list",",","optional",")",":","The","key","which","is","not","need","will","be","delete","to","accellect","data","reader",".","Default",":","None",".","if_rssn","(","bool",",","optional",")",":","Whether","to","use","RSSN","while","Compositing","image",".","Including","denoise","and","blur",".","Default",":","False","."]
code: def composite(self, fg, alpha, ori_bg):
      if self.if_rssn:
          if np.random.rand() < 0.5:
              fg = cv2.fastNlMeansDenoisingColored(
                  fg, None, 3, 3, 7, 21
              )
              ori_bg = cv2.fastNlMeansDenoisingColored(
                  ori_bg, None, 3, 3, 7, 21
              )
          if np.random.rand() < 0.5:
              radius = np.random.choice([19, 29, 39, 49, 59])
              ori_bg = cv2.GaussianBlur(ori_bg, (radius, radius), 0, 0)
      fg_h, fg_w = fg.shape[:2]
      ori_bg_h, ori_bg_w = ori_bg.shape[:2]
  
      wratio = fg_w / ori_bg_w
      hratio = fg_h / ori_bg_h
      ratio = wratio if wratio > hratio else hratio
  
      # Resize ori_bg if it is smaller than fg.
      if ratio > 1:
          resize_h = math.ceil(ori_bg_h * ratio)
          resize_w = math.ceil(ori_bg_w * ratio)
          bg = cv2.resize(
              ori_bg,
              (resize_w, resize_h),
              interpolation=cv2.INTER_LINEAR,
          )
      else:
          bg = ori_bg
  
      bg = bg[0:fg_h, 0:fg_w, :]
      alpha = alpha / 255
      alpha = np.expand_dims(alpha, axis=2)
      image = alpha * fg + (1 - alpha) * bg
      image = image.astype(np.uint8)
      return image, fg, bg
  
file_path: PaddleSeg/Matting/ppmatting/datasets/matting_dataset.py
imports: import os
  import math
  import cv2
  import numpy
  import random
  import paddle
  from paddleseg.cvlibs import manager
  import ppmatting.transforms
label_desc: Use image node_id 4 for calling the MattingDataset obj's underlying member method code with example usage: obj.composite(fg, alpha, ori_bg) and returns: image,  fg,  bg