I am following a tutorial on Cinder where you load and display images as cinder::gl::Texture
objects. This class has no convert2Grayscale
method, so
is it possible to implement something like that on my own ? Do I have access on separete pixels where I could apply a simple algorithm? (Accessing pixels is actually more important as I want to use this for another project)
Each pixel is represented by a 3D vector [R,G,B] Where R is the value in [0,1] of the red channel, G is the value in [0,1] of the green channel and B is the value in [0,1] of the blue channel. The easiest way to turn a 3D RGB pixel into a scalar Y which will represent light intensity in [0,1] (i.e., gray-scale) is to use the following formula:
Y = .2126 * R^gamma + .7152 * G^gamma + .0722 * B^gamma
Where gamma in most systems is equal to 2.2
Now as far as it concerns the access to pixels of an image in cinder you will have to load your image on a Surface object. Surface objects in cinder have interface functions for accessing individual pixels. See this amazing tutorial on how to do it: http://www.creativeapplications.net/tutorials/images-in-cinder-tutorials-cinder/