Transforming image contrast and brightness
In this recipe we will cover
basic image color transformations using the Surface
class for pixel manipulation.
Getting ready
To change the values of contrast and brightness we will use InterfaceGl
covered in Chapter 2, Preparing for Development in the Setting up GUI for parameters tweaking recipe. We will need a sample image to proceed with; save it in your assets
folder as image.png
.
How to do it...
We will create an application with simple GUI for contrast and brightness manipulation on the sample image. Perform the following steps to do so:
Include necessary headers:
#include "cinder/gl/gl.h" #include "cinder/gl/Texture.h" #include "cinder/Surface.h" #include "cinder/ImageIo.h"
Add properties to the main class:
float mContrast,mContrastOld; float mBrightness,mBrightnessOld; Surface32f mImage, mImageOutput;
In the
setup
method an image is loaded for processing and theSurface
object is prepared to store processed image:mImage = loadImage( loadAsset(...