CImg src(\"image.jpg\");
int width = src.width();
int height = src.height();
unsigned char* ptr = src.data(10,10);
How can I
The easiest way to access data is with the () operator:
unsigned char r = img(10,10,0,0);
unsigned char g = img(10,10,0,1);
unsigned char b = img(10,10,0,2);
You are probably hitting confusion because CImg stores the raw data non-interleaved. i.e. your raw data is stored R1, R2, ..., G1, G2, ..., B1, B2, ... instead of R1, G1, B1, R2, G2, B2, ... see: http://cimg.eu/reference/group__cimg__storage.html
.data() just returns a pointer, so to access the data directly as above you would do:
CImg src("image.jpg");
int width = src.width();
int height = src.height();
unsigned char* ptr = src.data(10,10);
unsigned char r = ptr[0];
unsigned char g = ptr[0+width*height];
unsigned char b = ptr[0+2*width*height];