我正在创建一个迭代图像并进行 x/y 变换和缩放的过程。原始图像非常大。我当前的过程涉及制作一个 bash 脚本(使用 python)以使用著名的 Imagemagick Convert 创建行和行。使用 convert 的主要优点是您可以将图像加载到内存中一次,然后写出每一帧。然而,这个 bash 脚本工作流是不可持续的,我需要一些更原生的东西。所以这引出了一个问题:
- 最快的图像 python 处理库是什么 操纵?考虑到图像可以有多大,速度是 目标。
这是我的研究(和一些修补)引导我的地方:
Wand (Imagemagick wrapper) - Theoretically, Wand would be great! But I have found no mention of being able to read the image from memory, which makes it VERY slow.
Skimage - I'd love to use Skimage for the depth of the operations (though overkill for my needs), but I've found the API/Documentation very difficult to work with. However, the fact that you can load an image into a numpy array and get breakneck speeds (for Python, anyways), seems like a compelling argument.
PIL - Pil can be very tricky to install, which has caused a lot of trouble on a few systems I'm trying to deploy. The API, though, it's pretty darn easy. I've heard generally to stay away from PIL due to it's ongoing development woes.
Pillow - Similar to above, I've had some trouble getting Pillow working. I think I read that Pillow can conflict with PIL... maybe that's the problem?
我希望得到一些意见。
请您参考如下方法:
这对于单个评论来说太长了。所以我把它放在这里。
请注意,除了 ImageMagick 之外,我不是任何这些工具的专家,但对每个工具都略有涉猎。
我欢迎其他比我更擅长这些工具的人发表评论或意见
我没有经常使用 Wand 或 PIL。我不喜欢 PIL,因为根据我有限的经验,如果不重新格式化,它与 numpy 不兼容。所以我不使用它。如果您喜欢 ImageMagick convert,Wand 看起来不错。我将 Skimage 和 OpenCV 用于不同的事情。并将它们混合在一些 Python numpy 脚本中。
如果您了解 ImageMagick,Wand 可能是最容易使用的。我不太了解它的速度。参见 http://docs.wand-py.org/en/0.4.1/wand/image.html .我认为存在的一个 Wand 限制是它缺少处理配置文件的能力。
参见 http://pillow.readthedocs.io/en/3.1.x/reference/Image.html对于 PIL,这可能是下一个最容易使用的。但它的图像格式可能需要更改格式才能与 numpy 一起使用。我认为它不如 Wand 功能齐全。
另见 http://scikit-image.org/docs/dev/api/skimage.transform.html用于旋转、调整大小和仿射变换。它是下一个最容易使用的,但可能比其他两个更快。
另见 https://docs.opencv.org/3.0-beta/doc/py_tutorials/py_imgproc/py_geometric_transformations/py_geometric_transformations.html ,尽管你必须用矩阵来做所有这些。它也非常快并且具有 GPU 功能。
除了我发现 Skimage 和 OpenCV 比 Imagemagick 更快之外,我没有计时方面的经验。但是除了我上面的评论之外,它们对于 Imagemagick 可以做的简单事情的直接功能不那么直接。
我认为您必须决定您希望在编码速度和效率方面做出什么样的妥协。
如果有人知道一组编码和速度测试,比较这些工具在调整大小、旋转、裁剪、仿射、透视等简单操作上的效果,那将很有用,我很乐意了解更多关于这些比较的信息。
附言我发现这些关于 PIL 已过时并被 Pillow 取代的引用资料:
http://pillow.readthedocs.io/en/3.4.x/about.html http://pillow.readthedocs.io/en/3.4.x/installation.html
另见文档: https://pypi.python.org/pypi/Pillow/4.3.0 https://pillow.readthedocs.io/en/4.3.x/reference/Image.html
我还没有尝试过新版本的 Pillow。
