CvColorImage increase contrast

Hello!

How can i increase the contrast a CvColorImage ?
also im trying contrastStretch() get this [warning] ofxCvColorImage: contrastStretch(): not implemented

these functions exist for grayscale images, so maybe you can convert to ofxCvGrayscaleImages (creating a grayscale image for the red, green and blue channels) via

http://openframeworks.cc/documentation/ofxOpenCv/ofxCvColorImage.html#show_convertToGrayscalePlanarImages

then use the brightnessContrast() function on each of the channels (ie the red,green,blue ofxCvGrayscaleImages):

http://openframeworks.cc/documentation/ofxOpenCv/ofxCvGrayscaleImage.html

then convert back to color with:

http://openframeworks.cc/documentation/ofxOpenCv/ofxCvColorImage.html#show_setFromGrayscalePlanarImages

2 Likes

Great! i will give i try.
Many thanks zach.

Here is the code if someone needed:

ofxCvColorImage photoCV;
ofImage fotoA;
ofxCvGrayscaleImage r,g,b;

photoCV.setFromPixels(fotoA.getPixelsRef());
photoCV.convertToGrayscalePlanarImages(r, g, b);

r.brightnessContrast(.2, .7);
g.brightnessContrast(.2, .7);
b.brightnessContrast(.2, .7);


photoCV.setFromGrayscalePlanarImages(r, g, b);

photoCV.flagImageChanged();
photoCV.draw(0,0,500,500);
1 Like