CImg<unsigned char> src("image.jpg");
int width = src.width();
int height = src.height();
unsigned char* ptr = src.data(10,10);
How can I get rgb from ptr?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
From the CImg documentation — section 6.13 on page 34, and section 8.1.4.16 on page 120 — it looks like the
datamethod can take four arguments: x, y, z, and c:…where
crefers to the color channel. I’m guessing that if your image is indeed an RGB image, then using values of 0, 1, or 2 forcwill give you the red, green, and blue components at a givenx, ylocation.For example:
(But this is just a guess!)
Edit:
It looks like there’s also an operator() for CImg that works in a similar manner: