mata mata - 1 year ago 104
C++ Question

Convert jpeg using gamma correction in c++

I have an image img.jpg and I want to convert it to newImg.jpg using the linear gamma correction. I found out how I can do it using the terminal:

convert img.jpg -gamma valueOfgamma newImg.jpg

But now I want to do it in my C++ program. How can I do that using imagemagick++ or openCv?


Answer Source

With you would use method Magick::Image.gamma(const double).

#include <Magick++.h>

int main(int argc, const char * argv[]) {
    double valueOfgamma = 1.0;

    // convert img.jpg -gamma valueOfgamma newImg.jpg
    Magick::Image image("img.jpg");

    return 0;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download