【问题标题】:How to convert scikit image to byte stream?如何将 scikit 图像转换为字节流?
【发布时间】:2017-10-30 19:35:53
【问题描述】:

如何转换从文件读取的scikit 图像:

from skimage import io
img = io.imread(f)

到像image_binary这样的字节流如下:

import io
from PIL import Image

image = Image.open("group1.jpeg")
stream = io.BytesIO()
image.save(stream,format="JPEG")
image_binary = stream.getvalue()

我在下面的link 中看到如何转换为cv2 图像,但不能转换为字节流。

【问题讨论】:

    标签: python python-3.x python-imaging-library scikit-image


    【解决方案1】:

    这是我最终使用的:

    from PIL import image
    from skimage import io
    
    img = io.imread(f)
    image = Image.fromarray(img.astype('uint8'), 'RGB')
    # ...
    

    【讨论】:

      猜你喜欢
      • 2015-10-17
      • 2016-09-27
      • 1970-01-01
      • 2019-12-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-13
      • 1970-01-01
      相关资源
      最近更新 更多