add readme.md
This commit is contained in:
@@ -14,25 +14,16 @@ class DataLoadUtil:
|
||||
|
||||
@staticmethod
|
||||
def load_exr_image(file_path):
|
||||
# 打开 EXR 文件
|
||||
exr_file = OpenEXR.InputFile(file_path)
|
||||
|
||||
# 获取 EXR 文件的头部信息,包括尺寸
|
||||
header = exr_file.header()
|
||||
dw = header['dataWindow']
|
||||
width = dw.max.x - dw.min.x + 1
|
||||
height = dw.max.y - dw.min.y + 1
|
||||
|
||||
# 定义通道,通常法线图像是 RGB
|
||||
float_channels = ['R', 'G', 'B']
|
||||
|
||||
# 读取 EXR 文件中的每个通道并转化为浮点数数组
|
||||
img_data = []
|
||||
for channel in float_channels:
|
||||
channel_data = exr_file.channel(channel, Imath.PixelType(Imath.PixelType.FLOAT))
|
||||
img_data.append(np.frombuffer(channel_data, dtype=np.float32).reshape((height, width)))
|
||||
|
||||
# 将各通道组合成一个 (height, width, 3) 的 RGB 图像
|
||||
img = np.stack(img_data, axis=-1)
|
||||
return img
|
||||
|
||||
|
Reference in New Issue
Block a user