Ask Your Question

How can i add all 'R' values in the image?

asked 2015-01-07 03:58:10 -0500

guru gravatar image

I need to add all the R values in the image . How can i do this?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2015-01-07 04:12:45 -0500

berak gravatar image

updated 2015-01-07 04:13:25 -0500

there's a builtin sum function for that:

e.g. if you have a (bgr) image:

Mat img = imread("my.png");
Scalar s = sum(img);
//s[0] = sum of blue channel,
//s[1] = sum of green channel,
//s[2] = sum of red channel,
edit flag offensive delete link more

Question Tools

1 follower


Asked: 2015-01-07 03:58:10 -0500

Seen: 577 times

Last updated: Jan 07 '15