OpenCV has quite good performance. It should be sufficient for most cases.
To improve performance, you can also use OpenCV together with Intel IPP, which is however a non-free commercial product. If OpenCV detects that IPP is installed it will use it where possible.
As a third option you can use IPP directly. IPP was designed with high performance (on Intel architectures) as a goal. It is optimized to use the intel SIMD instructions.
Answer from Dani van der Meer on Stack OverflowOpenCV has quite good performance. It should be sufficient for most cases.
To improve performance, you can also use OpenCV together with Intel IPP, which is however a non-free commercial product. If OpenCV detects that IPP is installed it will use it where possible.
As a third option you can use IPP directly. IPP was designed with high performance (on Intel architectures) as a goal. It is optimized to use the intel SIMD instructions.
imagemagick is quite popular.
C++ Image Processing Libraries - Stack Overflow
Real-time image processing library that isn't actually C++?
Resources to learn C for image processing and computer vision
Any simple image libraries for C#?
Videos
Magick++ might help. It's the library version of ImageMagick.
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.
I'm looking for a real-time image processing library which must be written in C for portability, but anything I search for brings only C++ up, unsurprisingly.
It cannot be written in anything else and simply use a C interface.