Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Library for basic image manipulation in C++

I am looking for a great C++ library for doing basic image manipulation. What I need done is to be able to convert an image to grayscale and have access to read the pixels of the image.

I have looked at OpenCV, GIL, CImg and Magick++, but either they were not too great, or I couldn't figure out how to convert an image to grayscale with the library.

like image 840
chrisbuchholz Avatar asked Mar 25 '11 00:03

chrisbuchholz


2 Answers

If you're going to convert color to greyscale on your own, you don't normally want to give equal weight to the three channels. The usual conversion is something like:

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

Obviously those factors aren't written in stone, but they should be reasonably close.

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

like image 185
Jerry Coffin Avatar answered Sep 30 '22 17:09

Jerry Coffin


CImg is probably easiest to use, no install it's just a header file

like image 32
Martin Beckett Avatar answered Sep 30 '22 16:09

Martin Beckett