def write_pfm(data, fpath, scale=1, file_identifier="Pf", dtype="float32"):
# PFM format definition: http://netpbm.sourceforge.net/doc/pfm.html
data = np.flipud(data)
height, width = np.shape(data)[:2]
values = np.ndarray.flatten(np.asarray(data, dtype=dtype))
endianess = data.dtype.byteorder
if endianess == '<' or (endianess == '=' and sys.byteorder == 'little'):
scale *= -1
with open(fpath, 'wb') as ff:
ff.write(file_identifier + '\n')
ff.write('%d %d\n' % (width, height))
ff.write('%d\n' % scale)
ff.write(values)
评论列表
文章目录