使用skimage如何获取图像格式?

huangapple go评论47阅读模式
英文:

How to get image format using skimage?

问题

使用skimage编写上述代码应该如下所示:

import skimage.io
from PIL import Image

im = skimage.io.imread('abc.jpg')
print(Image.fromarray(im).format)

请注意,只有代码部分需要翻译,所以我只翻译了代码部分,不包括问题或注释。

英文:
from PIL import Image
im = Image.open('abc.jpg')
print(im.format) //output: JPEG

How can I write the above code using skimage?

I tried:

import skimage
from PIL import Image
im = skimage.io.imread('abc.jpg')
print(Image.fromarray(im).format)

Did not work for me.

答案1

得分: 1

我不认为你可以使用skimage来做到这一点。

当你使用PIL加载图片时,像这样:

im = Image.open(path)

它会返回一个PIL Image对象,其中存储了宽度、高度、颜色空间、调色板和EXIF数据。

当你使用skimage加载图片时,它只会返回一个纯粹的Numpy数组,对应于像素颜色,因此没有地方来存储格式或其他任何信息。

英文:

I don't think you can do that with skimage.

When you load an image with PIL like this:

im = Image.open(path)

it returns a PIL Image object which stores the width, height, colourspace, palette and EXIF data.

When you load an image with skimage it just returns a pure Numpy array corresponding to the pixel colours so there is no place to store the format or anything else.

huangapple
  • 本文由 发表于 2020年1月6日 21:26:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/59612969.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定