最快的 C/C++ 图像大小调整库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/873976/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 17:42:47  来源:igfitidea点击:

Fastest C/C++ image resizing library

c++cimageresize

提问by The Unknown

I am writing a application that needs to resize massive amounts of images... and these are my requirements:

我正在编写一个需要调整大量图像大小的应用程序......这些是我的要求:

  • C/C++
  • Support jpeg/png at least
  • Fast
  • Cross-Platform
  • C/C++
  • 至少支持 jpeg/png
  • 快速地
  • 跨平台

So far my options are:

到目前为止,我的选择是:

  • OpenCV
  • CImg
  • ImageMagick
  • GraphicsMagick (it's said to be fast)
  • DevIL
  • GIL from Boost
  • CxImage
  • Imlib2 (it's said to be fast)
  • Any others?
  • OpenCV
  • 氯化镁
  • 图像魔术师
  • GraphicsMagick(据说速度很快)
  • 魔鬼
  • 来自 Boost 的 GIL
  • 图像
  • Imlib2(据说速度很快)
  • 还有其他人吗?

All of these would get the job done, but I am looking for the fastesthere, and I was not able to find any benchmarks on their performance.

所有这些都可以完成工作,但我在这里寻找最快的,我找不到任何关于它们性能的基准。

采纳答案by Shay Erlichmen

Take a look at Intel IPP (Integrated Performance Primitives)(Wiki link is better then the Intel one...) it works also on AMD and has functions to resize images (bilinear, nearest neighbor, etc) and works on Linux and Windows.

看看英特尔 IPP(集成性能基元)(Wiki 链接比英特尔更好……)它也适用于 AMD,并具有调整图像大小(双线性、最近邻等)的功能,并且适用于 Linux 和 Windows。

It is not free (but it won't break the bank), but its the fastest that you can find.

它不是免费的(但它不会破坏银行),但它是你能找到的最快的。

回答by Shay Erlichmen

Take a look at VIPS. It's the fastest one I've found so far, and is free for commercial use.

看看VIPS。这是迄今为止我发现的最快的一个,并且可以免费用于商业用途。

https://github.com/libvips/libvips/wiki/Speed-and-memory-use

https://github.com/libvips/libvips/wiki/Speed-and-memory-use

On that benchmark, it's 2x faster than Pillow-SIMD, 5x faster than imagemagick, 6x faster than opencv, 8x faster than freeimage, etc. It has dramatically lower memory use too: more than 10x less than imagemagick, for example.

在该基准测试中,它比 Pillow-SIMD 快 2 倍,比 imagemagick 快 5 倍,比 opencv 快 6 倍,比 freeimage 快 8 倍,等等。它的内存使用也显着降低:例如,比 imagemagick 少 10 倍以上。

回答by timday

If IPPdoes what you need(e.g function Resize in section 12), then I doubt you'll find signifcantly faster x86 code anywhere else. Bear in mind that it may fall back onto slower "reference implementations" when run on AMD CPUs though.

如果IPP你需要什么(例如,功能调整尺寸在第12节),那么我怀疑你会发现signifcantly更快的x86代码其他地方。请记住,在 AMD CPU 上运行时,它可能会退回到较慢的“参考实现”。

If CPU isn't meeting your performance requirements, you might consider pushing the resizing onto a GPU using OpenGL (the simplest implementation using texture mapping would benefit from hardware interpolators, for more complex filtering use GLSL shader code). The ability of the GPU to do this sort of thing about a hundred times faster than a CPU (give or take a zero) has to be weighed against the relatively slow data transfer to and from the card though (typically a gigabyte or two per second at the most).

如果 CPU 不能满足您的性能要求,您可以考虑使用 OpenGL 将调整大小推送到 GPU(使用纹理映射的最简单实现将受益于硬件插值器,对于更复杂的过滤使用 GLSL 着色器代码)。GPU 执行此类操作的能力比 CPU(给出或取零)快一百倍,但必须权衡进出卡的相对较慢的数据传输(通常每秒 1 GB 或 2 个)至多,最多)。

回答by Leo Davidson

@Chris Becke's comment:

@Chris Becke 的评论:

"think for just a moment about that statement. What part of doing it in a single (complicated) step is going to make it any faster? The image decoding routines still need to decode every pixel in order for the filter routines to filter them."

“想一想那句话。在单个(复杂的)步骤中执行它的哪一部分会使其更快?图像解码例程仍然需要解码每个像素,以便过滤器例程对其进行过滤。 ”

That isn't always the case. For example, when decoding a JPEG you can ask the JPEG library to give you a 1/2, 1/4, 1/8 size image (or something like that; it's a while since I've looked in detail) which it can do without having to decode the extra detail at all, due to the way JPEG works. It can be much quicker than a full decode + scale.

情况并非总是如此。例如,在解码 JPEG 时,您可以要求 JPEG 库为您提供 1/2、1/4、1/8 大小的图像(或类似的图像;我已经有一段时间没有详细查看了)它可以由于 JPEG 的工作方式,因此根本无需解码额外的细节。它可以比完整的解码 + 缩放快得多。

(Obviously you may need to scale a bit afterwards if the smaller image isn't the exact size you want.)

(显然,如果较小的图像不是您想要的确切尺寸,您可能需要稍后缩放。)

(Sorry I can only post this reply as a comment due to no reputaton. First time I've tried to post anything here. If someone wants to repost this or something similar as a comment and delete my answer, feel free!)

(抱歉,由于没有声誉,我只能将此回复作为评论发布。我第一次尝试在此处发布任何内容。如果有人想重新发布此或类似评论并删除我的答案,请随意!)

回答by R Ubben

If you are looking for open source, how about FreeImage? For commercial stuff, I use Snowbound. Both are quite fast and capable of many different image formats and resizing algorithms.

如果您正在寻找开源,FreeImage 怎么样?对于商业内容,我使用 Snowbound。两者都非常快,并且能够处理许多不同的图像格式和大小调整算法。

回答by Olivier Pons

If you're looking for free stuff, and want to do things quickly, try to develop a Gimp C-compiled plugin : this is very easy, and I think Gimp does a good job at resizing :

如果您正在寻找免费的东西,并且想要快速做事,请尝试开发一个 Gimp C 编译插件:这很容易,而且我认为 Gimp 在调整大小方面做得很好:

This may not be the fastest to resize, but the cheapest (free) and the fastest to develop.

这可能不是调整大小最快的,而是最便宜(免费)和开发最快的。

Take a look there.

看看那里