The easiest way to properly adjust the brightness, contrast and gamma of the image. The word "right" is here because I know how to make these adjustments incorrectly: iterate over all the RGB pixels and do the following for each channel:
int changeBrightness( int value, int brightness) {
return qBound<int>(0, value + brightness * 255 / 100, 255);
}
int changeContrast( int value, int contrast ) {
return qBound<int>(0, int(( value - 127 ) * contrast / 100 ) + 127, 255 );
}
int changeGamma( int value, int gamma ) {
return qBound<int>(0, int( pow( value / 255.0, 100.0 / gamma ) * 255 ), 255 );
}
Although this code will add the effect of changing the brightness / contrast / gamma, it does not look very good. Professional image processing software like Photoshop is much better.
What is the best library dealing with such things? I know that there is ImageMagick, but it is very heavy, I do not want to refer to only one feature of hundreds. Are there any easy alternatives?
source
share