Skimage imread返回img\u arrayndarray;属性是什么?

2024-10-02 10:22:12 发布

您现在位置:Python中文网/ 问答频道 /正文

真的很惊讶,但是我找不到任何关于img_arrayndarray的文档,skimage的imread返回的是这个文档。

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

我的主要问题是这个对象有什么属性/方法等。

或者,文件如此缺乏是有原因的吗?例如,将imread转换为numpy数组是一种常见的做法吗?谢谢


Tags: 对象文档httpsioorgdevimageapi
2条回答

有关Stefan's answer的详细信息:

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

您可以在这里看到受支持的插件https://scikit-image.org/docs/dev/api/skimage.io.html,以及通过调用skimage.io.find_available_plugins为他或她自己的环境提供的插件。 {a5}下面的插件^是特定的。在

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

测试功能,
使用Python 2.7.13、Ipython 5.1.0、skimage 0.13.0、
以及python3.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

您指向文档的链接是skimage0.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.

相关问题 更多 >

    热门问题