def load_pfm(filepath, reverse = 1):
file = open(filepath, 'rb')
color = None
width = None
height = None
scale = None
endian = None
header = file.readline().rstrip()
color = (header == 'PF')
width, height = map(int, file.readline().strip().split(' '))
scale = float(file.readline().rstrip())
endian = '<' if(scale < 0) else '>'
scale = abs(scale)
rawdata = np.fromfile(file, endian + 'f')
shape = (height, width, 3) if color else (height, width)
file.close()
if(color):
return rawdata.reshape(shape).astype(np.float32)[:,:,::-1]
else:
return rawdata.reshape(shape).astype(np.float32)
评论列表
文章目录