Skimage imread返回img_arrayndarray;有什么特性?

时间:2019-05-03 20:26:17

标签: python image computer-vision scikit-image vision

真的很惊讶,但我找不到img_arrayndarray上的任何文档,这是skimage的未读内容返回的内容。

https://scikit-image.org/docs/dev/api/skimage.io.html#skimage.io.imread

我的主要问题是此对象具有哪些属性/方法等。

或者,是否有文档如此缺乏的原因?例如,通常将阅读内容转换为numpy数组吗?谢谢

2 个答案:

答案 0 :(得分:2)

测试功能,
使用Python 2.7.13,Ipython 5.1.0,skimage 0.13.0,
和Python 3.6.7,Ipython 7.4.0,skimage 0.15.0:

 In [1]: from skimage import io

 In [2]: a = io.imread('testimg.tif')

 In [3]: type(a)  
 Out[3]: numpy.ndarray

您到文档的链接是skimage 0.16.0,但是我认为可以肯定地认为文档中只是有错字。

编辑:同时,查看source

def imread(fname, as_gray=False, plugin=None, flatten=None,
           **plugin_args):
    """Load an image from file.
    Parameters
    ----------
    fname : string
        Image file name, e.g. ``test.jpg`` or URL.
    as_gray : bool, optional
        If True, convert color images to gray-scale (64-bit floats).
        Images that are already in gray-scale format are not converted.
    plugin : str, optional
        Name of plugin to use.  By default, the different plugins are
        tried (starting with imageio) until a suitable
        candidate is found.  If not given and fname is a tiff file, the
        tifffile plugin will be used.
    Other Parameters
    ----------------
    plugin_args : keywords
        Passed to the given plugin.
    flatten : bool
        Backward compatible keyword, superseded by `as_gray`.
    Returns
    -------
    img_array : ndarray
        The different color bands/channels are stored in the
        third dimension, such that a gray-image is MxN, an
        RGB-image MxNx3 and an RGBA-image MxNx4.

答案 1 :(得分:1)

Stefan's answer的更多详细信息:

scikit-image并未在内部实现IO功能,而是将其包装并委托给外部库(称为"plugings")。

您可以在此处查看受支持的插件-https://scikit-image.org/docs/dev/api/skimage.io.html,并且可以通过调用skimage.io.find_available_plugins来在自己的环境中使用这些插件。 插件是按照特定的priority list加载的。

您看到的问题与其中一个插件中dtype验证中的错误有关。最近,imageio插件(https://github.com/scikit-image/scikit-image/pull/3837)的类似错误已得到修复,它将被合并到0.14.3(LTS),0.15.1 / 0.16(最新)发行版中。