PIL.Image.fromarray() 和 numpy.asarray()

Posted 怎样才能回到过去

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PIL.Image.fromarray() 和 numpy.asarray()相关的知识,希望对你有一定的参考价值。

1 将numpy.array 转换为 PIL.Image 类型

from PIL import Image
image = Image.fromarray(image)

2 将 PIL.Image 转换为 numpy.array 类型

import numpy as np
img = np.asarray(img)

以上是关于PIL.Image.fromarray() 和 numpy.asarray()的主要内容,如果未能解决你的问题,请参考以下文章