Click here to Skip to main content
15,881,092 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
So, i have a Mat image and i want to know the BGR value at a specific row and column in the image.
Here is the code that i tried but its not giving me correct values.

int newval[3];


img.at<cv::vec3b xmlns:cv="#unknown">(100,100)[0] = newval[0];
img.at<cv::vec3b>(100,100)[1] = newval[1];
img.at<cv::vec3b>(100,100)[2] = newval[2];

Please can anyone help me out. Thanks
Posted
Comments
[no name] 11-Jul-14 18:30pm    
"not giving me correct values"... I am not really surprised. It looks like you are trying to set the values not get the values. And, you are setting the values with garbage values since you did not initialize newval to anything.

Vec3b intensity = img.at<vec3b>(y, x);
uchar blue = intensity.val[0];
uchar green = intensity.val[1];
uchar red = intensity.val[2];

Try using this.
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900