Library for processing basic images in C ++

I am looking for a great C ++ library to do basic image manipulation. I need to do this in order to convert the image to grayscale and gain access to read the pixels of the image.

I watched OpenCV, GIL, CImg and Magick ++, but either they were not too large, or I could not figure out how to convert the image to grayscale using the library.

+7
source share
6 answers

CImg is probably the easiest to use, do not set it as a header file

+4
source

If you intend to convert the color to shades of gray yourself, you usually do not want to give equal weight to the three channels. A normal conversion is something like:

gray = 0.3 * R + 0.6 * G + 0.1 * B;

Obviously, these factors are not written in stone, but they should be close enough.

You can simulate different filter colors by changing factors - by far the most common filter in B&W photography is red, which means increasing red and decreasing the other two to maintain a common ratio of 1.0 (but keep the G: B ratio of about 6 : 1 or so).

+6
source

You can also look at CxImage (a library for processing and converting images in C ++).

+1
source

To the rough steps to do this with Cimg would be something like:

#include "CImg.h" using namespace cimg_library; ... { ... CImg<unsigned char> image("source.jpg") //[load jpg][2] needs ImageMagick cimg_for(img,ptr,float) { *ptr=0; } //[Loop][3] over every pixel, eg this method equivalent to 'img.fill(0);' save_jpeg (const char *const filename, const unsigned int quality=100) //[save as a jpg][4] ... } 
0
source

You can take a look at paintlib

0
source

ITK is a great library for image processing. You can convert RGB to grayscale using itk::RGBToLuminanceImageFilter .

0
source

All Articles