将深度图映射到颜色空间,是深度图更易查看,下面是颜色空间:

深度学习特征可视化方法 深度图可视化_Image

代码,需要做的就是把for循环里面的文件路径和转换后的输出文件夹改一下就可以直接使用python3运行,你可能需要先安装必要的python包,例如opencv-python、numpy和PIL:

import cv2
import os.path
import glob
import numpy as np
from PIL import Image
 
def convertPNG(pngfile,outdir):
    # READ THE DEPTH
    im_depth = cv2.imread(pngfile)
    #apply colormap on deoth image(image must be converted to 8-bit per pixel first)
    im_color=cv2.applyColorMap(cv2.convertScaleAbs(im_depth,alpha=15),cv2.COLORMAP_JET)
    #convert to mat png
    im=Image.fromarray(im_color)
    #save image
    im.save(os.path.join(outdir,os.path.basename(pngfile)))
 
for pngfile in glob.glob("./depth/000000000.png"):#C:/Users/BAMBOO/Desktop/source pics/rgbd_6/depth/*.png
    print(pngfile)
    convertPNG(pngfile,"seedepth")#C:/Users/BAMBOO/Desktop/source pics/rgbd_6/color