28 lines
979 B
Python
Executable File
28 lines
979 B
Python
Executable File
import cv2
|
|
import numpy as np
|
|
|
|
# 读取深度图像
|
|
depth_image_path = 'aucpuncture2point/configs/using_img/depth.png'
|
|
depth_image = cv2.imread(depth_image_path, cv2.IMREAD_UNCHANGED)
|
|
|
|
if depth_image is None:
|
|
raise ValueError(f"无法读取深度图像文件: {depth_image_path}. 请检查文件路径或格式。")
|
|
|
|
# 将深度图像归一化到 0-255 范围
|
|
depth_normalized = cv2.normalize(depth_image, None, 0, 255, cv2.NORM_MINMAX)
|
|
|
|
# 确保归一化后的图像是 8 位无符号整数
|
|
depth_normalized = np.uint8(depth_normalized)
|
|
|
|
# 确保 depth_normalized 是单通道图像
|
|
if len(depth_normalized.shape) == 2: # 如果是灰度图像
|
|
# 使用伪彩色映射
|
|
depth_colormap = cv2.applyColorMap(depth_normalized, cv2.COLORMAP_JET)
|
|
else:
|
|
raise ValueError("depth_normalized 不是单通道图像,无法应用伪彩色映射。")
|
|
|
|
# 显示伪彩色深度图像
|
|
cv2.imshow('Depth Image (Color Map)', depth_colormap)
|
|
cv2.waitKey(0)
|
|
cv2.destroyAllWindows()
|