utils.py 文件源码

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

项目:self-augmented-net 作者: msraig 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号