def Depth_TM(img, AtomsphericLight): DepthMap = depthMap(img) t0, t1 = 0.05, 0.95 DepthMap = DepthMap.clip(t0, t1) d_0 = minDepth(img, AtomsphericLight) d_f = 8 * (DepthMap + d_0) TM_R_modified = 0.85**d_f return TM_R_modified
files = os.listdir(path) files = natsort.natsorted(files) for i in range(len(files)): file = files[i] filepath = path + "/" + file prefix = file.split('.')[0] if os.path.isfile(filepath): print('******** file ********', file) img = cv2.imread(folder + '/InputImages/' + file) blockSize = 9 gimfiltR = 50 # 引导滤波时半径的大小 eps = 10**-3 # 引导滤波时epsilon的值 DepthMap = depthMap(img) DepthMap = global_stretching(DepthMap) guided_filter = GuidedFilter(img, gimfiltR, eps) refineDR = guided_filter.filter(DepthMap) refineDR = np.clip(refineDR, 0, 1) cv2.imwrite('ULAPDepthMap.jpg', np.uint8(refineDR * 255)) plt.subplot(311), plt.imshow(np.uint8(refineDR * 255)) plt.show() AtomsphericLight = BLEstimation(img, DepthMap) * 255 d_0 = minDepth(img, AtomsphericLight) d_f = 8 * (DepthMap + d_0) transmissionB, transmissionG, transmissionR = getRGBTransmissionESt( d_f)