code: def relighting(self, img, skybg, skymask):
      # color matching, reference: skybox_img
      step = int(img.shape[0] / 20)
      skybg_thumb = skybg[::step, ::step, :]
      img_thumb = img[::step, ::step, :]
      skymask_thumb = skymask[::step, ::step, :]
      skybg_mean = np.mean(skybg_thumb, axis=(0, 1), keepdims=True)
      img_mean = np.sum(
          img_thumb * (1 - skymask_thumb), axis=(0, 1), keepdims=True
      ) / ((1 - skymask_thumb).sum(axis=(0, 1), keepdims=True) + 1e-9)
      diff = skybg_mean - img_mean
      img_colortune = img + self.recoloring_factor * diff
  
      if self.auto_light_matching:
          img = img_colortune
      else:
          # keep foreground ambient_light and maunally adjust lighting
          img = self.relighting_factor * (
              img_colortune + (img.mean() - img_colortune.mean())
          )
  
      return img
  
file_path: PaddleHub/modules/video/Video_editing/SkyAR/skybox.py
imports: import cv2
  import numpy
  from .rain import Rain
  from .utils import build_transformation_matrix, update_transformation_matrix, estimate_partial_transform, removeOutliers, guidedfilter
label_desc: Use image node_id 7 for calling the SkyBox obj's underlying member method code with example usage: obj.relighting(img, skybg, skymask) and returns: img