def load_disp(filename): gt_disp = None if gt_disp_name.endswith('pfm'): gt_disp, scale = load_pfm(gt_disp_name) gt_disp = gt_disp[::-1, :] elif gt_disp_name.endswith('npy'): gt_disp = np.load(gt_disp_name) gt_disp = gt_disp[::-1, :] elif gt_disp_name.endswith('exr'): gt_disp = load_exr(filename) else: gt_disp = Image.open(gt_disp_name) gt_disp = np.ascontiguousarray(gt_disp, dtype=np.float32) / 256 return gt_disp
def load_norm(filename): gt_norm = None if filename.endswith('exr'): gt_norm = load_exr(filename) # transform visualization normal to its true value gt_norm = gt_norm * 2.0 - 1.0 ## fix opposite normal #m = gt_norm >= 0 #m[:,:,0] = False #m[:,:,1] = False #gt_norm[m] = - gt_norm[m] return gt_norm
def load_disp(filename): gt_disp = None if gt_disp_name.endswith('pfm'): gt_disp, scale = load_pfm(gt_disp_name) gt_disp = gt_disp[::-1, :] elif gt_disp_name.endswith('npy'): gt_disp = np.load(gt_disp_name) gt_disp = gt_disp[::-1, :] elif gt_disp_name.endswith('exr'): gt_disp = load_exr(filename) else: f_in = np.array(Image.open(gt_disp_name)) d_r = f_in[:, :, 0].astype('float32') d_g = f_in[:, :, 1].astype('float32') d_b = f_in[:, :, 2].astype('float32') gt_disp = d_r * 4 + d_g / (2**6) + d_b / (2**14) return gt_disp