text: import os
  import os.path as osp
  import cv2
  import numpy as np
  
  
  def walk_dir(path):
      dir_list = []
      for root, dirnames, files in os.walk(path):
          for dirname in dirnames:
              dir_list.append(os.path.join(root, dirname))
      return dir_list
  
  def create_crop(img1,img2,img3,x,y,w,h,save_path):
      shape = img1.shape
      save_crop = np.ones((h+60, w*3+40, shape[2]))
      crop1 = img1[y:h+y, x:w+x]
      crop2 = img2[y:h+y, x:w+x]
      crop3 = img3[y:h+y, x:w+x]
      save_crop[10:h+10, 10:w+10,:], save_crop[10:h+10, w+20:2*w+20,:], save_crop[10:h+10, 2*w+30:3*w+30,:] = crop1,crop2,crop3
      cv2.putText(save_crop, 'gt', (w//2 - 5, h+40), fontFace=cv2.FONT_HERSHEY_SIMPLEX, fontScale=1, color=(255,255,255), thickness=2)
      cv2.putText(save_crop, 'd335', ((3*w + 40) // 2 - 20, h+40), fontFace=cv2.FONT_HERSHEY_SIMPLEX, fontScale=1, color=(255,255,255), thickness=2)
      cv2.putText(save_crop, 'bic', (2*w + w//2 - 20, h+40), fontFace=cv2.FONT_HERSHEY_SIMPLEX, fontScale=1, color=(255,255,255), thickness=2)
      cv2.imwrite(save_path, save_crop)
  
  def crop_folder(path1, path2, path3, save_path, frame_num):
      path1_list = walk_dir(path1)
      path2_list = walk_dir(path2)
      path3_list = walk_dir(path3)
      
      for i in range(len(path1_list)):
          basename = os.path.basename(path1_list[i])
          save_img_name = os.path.join(save_path, f'{basename}_{frame_num}.png')
          gt_img = cv2.imread(os.path.join(path1_list[i], f'frame{frame_num:03d}.png')) 
          vsr_img = cv2.imread(os.path.join(path2_list[i], f'frame{frame_num:03d}_BasicVSR.png'))
          bic_img = cv2.imread(os.path.join(path3_list[i], f'frame{frame_num:03d}.png'))
          create_crop(img1=gt_img,img2=vsr_img,img3=bic_img,x=300,y=300,w=200,h=200,save_path=save_img_name)
  
  
  def main():
      # save_path = 'results/img_crop/IMG_2558.jpg'
      # gt = cv2.imread('datasets/HLG/rgb18/val_gt/hdr/IMG_2558/frame000.png')
      # d234 = cv2.imread('results/BasicVSR/my_pretrained/HLG/d234/rgb18_8/hdr/IMG_2558/frame000_BasicVSR.png')
      # reds = cv2.imread('results/BasicVSR/my_pretrained/REDS/hdr/IMG_2558/frame000_BasicVSR.png')
      # create_crop(img1=gt,img2=d234,img3=reds,x=300,y=300,w=200,h=200,save_path=save_path)
      save_path_folder = 'results/img_crop/d335'
      os.makedirs(save_path_folder, exist_ok=True)
      gt_path_folder = 'datasets/HLG/rgb18/val_gt/hdr'
      vsr_path_folder = 'results/BasicVSR/my_pretrained/HLG/d335'
      bic_path_folder = 'datasets/HLG/rgb18/val_bic/hdr'
      crop_folder(gt_path_folder, vsr_path_folder, bic_path_folder, save_path_folder, 15)
  
  
  if __name__ == '__main__':
      main()
  