file_io.py 文件源码

python
阅读 36 收藏 0 点赞 0 评论 0

项目:evaluation-toolkit 作者: lightfield-analysis 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号