utils.py 文件源码

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

项目:main_loop_tf 作者: fvisin 项目源码 文件源码
def fig2array(fig):
    """Convert a Matplotlib figure to a 4D numpy array

    Params
    ------
    fig:
        A matplotlib figure

    Return
    ------
        A numpy 3D array of RGBA values

    Modified version of: http://www.icare.univ-lille1.fr/node/1141
    """
    # draw the renderer
    fig.canvas.draw()

    # Get the RGBA buffer from the figure
    w, h = fig.canvas.get_width_height()
    buf = np.fromstring(fig.canvas.tostring_rgb(), dtype=np.uint8)
    buf.shape = (h, w, 3)

    return buf
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号