I am looking for a C++ library for image processing. I need the library to threshold a PPM photo (color photo). Should I write my own code? what do you guys think?
7 Answers
All of the above options should be able to do what you required.
I would like to add OpenCV to the list. It's a fast cross-platform computer vision library with extensive image loading, saving and processing support. It's written in C, but it has a solid C++ interface, which I have used in the past.
That being said: Reading / writing PPMs is straight-forward, so if all you need is to read and threshold, you should definitely consider doing it yourself. It would come down to reading the PPM bytes into memory, greyscaling by averaging the RGB color channels (note that averaging the RGB channels is one, very simple, method to greyscale; there are more), then thresholding and writing away.

- 4,373
- 34
- 53
You could use Boost GIL library. It's extremely powerful and versatile and may actually suit all your needs (well, yep, it's boost :).

- 4,945
- 2
- 26
- 27
-
2Please update the link to [Boost GIL](https://www.boost.org/doc/libs/master/libs/gil/doc/html/index.html). So it points always to the current version. – Benjamin Buch Jan 15 '21 at 09:55
The Simd Library The is a free open source image processing library, designed for C and C++ programmers. It provides many useful high performance algorithms for image processing such as: pixel format conversion, image scaling and filtration, extraction of statistic information from images, motion detection, object detection (HAAR and LBP classifier cascades) and classification, neural network.
The algorithms are optimized with using of different SIMD CPU extensions. In particular the library supports following CPU extensions: SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX, AVX2 and AVX-512 for x86/x64, VMX(Altivec) and VSX(Power7) for PowerPC, NEON for ARM.
The Simd Library has C API and also contains useful C++ classes and functions to facilitate access to C API. The library supports dynamic and static linking, 32-bit and 64-bit Windows and Linux, MSVS, G++ and Clang compilers, MSVS project and CMake build systems.
P.S. I participate in the development of this project.
-
It seems like a cool library! Are you also the author? If so, you should probably mention it in the answer (see [affiliation disclosure](http://stackoverflow.com/help/behavior)) – Erik Sjölund Aug 17 '15 at 20:37
-
-
Does Simd library has any feature that would combine two images vertically such that (500x500, 500x500) becomes (500x1000)? I haven't learned C++ yet and I am trying to find a library that can do this (to be used in android). Can you help – rupinderjeet Mar 07 '17 at 10:41
-
3@rupinderjeet Of course, Simd Library allows to do this: Simd::Copy(a, c.Region(0, 0, 500, 500).Ref()); Simd::Copy(b, c.Region(0, 500, 1000, 500).Ref()); – ErmIg Mar 07 '17 at 11:06
The CImg Library is a popular choice too. It is really simple to use, lightweight and already have a lot of basic and advanced image processing operators implemented.

- 61
- 1
- 1
Very good library is GD2
This library has multiple languages bindings, including C (which is compatible with C++ of course). It is easy to build GD as a static or dynamic library with actually any C++ compiler, including GCC and Visual C++, also pre-built binaries are available over Internet. Unlike Boost image library, it allows to load/save images from/to memory and not hard drive only.

- 4,434
- 4
- 35
- 77