opencv的imread()读取深度图的通道变化问题

opencv的imread()读取深度图的通道变化问题

今日楼主在查看来自ScanNet的深度图时候,发现图片有部分的区域是白色的,想看看他的具体深度值,想到可以用opencv或者PIL打开,结果发现了这样的问题

import cv2
from PIL import Image 
import numpy as np

path = "/home/chan/Desktop/1.png" # RGB彩色图
path2 = "/home/chan/Desktop/2.png" #深度图
image = cv2.imread(path)
image2 = cv2.imread(path2)

#print(image.shape[0])
#print(image.shape[1])
print('cv read image.shape is',image.shape)
print('cv read image2.shape is',image2.shape)

image = Image.open(path) # 用PIL中的Image.open打开图像 
image_arr = np.array(image) # 转化成numpy数组

image2 = Image.open(path2) # 用PIL中的Image.open打开图像 
image_arr2 = np.array(image2) # 转化成numpy数组
print('numpy read image_arr.shape is ',image_arr.shape)
print('numpy read image_arr2.shape is ',image_arr2.shape)

output:

cv read image.shape is (480, 640, 3)
cv read image2.shape is (480, 640, 3)
numpy read image_arr.shape is  (480, 640)
numpy read image_arr2.shape is  (480, 640, 3)

opencv的imread()读取深度图时候会出现3通道的情况,而实际上在win系统下打开是8位的,即是一通道的图像;用PIL库转成数组的形式也是一通道的二维数组,于是楼主打开了我的www.baidu.com。

你可能感兴趣的:(opencv的imread()读取深度图的通道变化问题)