Ask Your Question
1

Add scalar to particular channel of an opencv image?

asked 2015-09-16 08:21:52 -0600

erogol2 gravatar image

updated 2015-09-16 14:16:05 -0600

What is the most efficient way to add scalar to a particular channel of an opencv image?

edit retag flag offensive close merge delete

Comments

Have you tried image + cv::Scalar(alpha, blue, green, red)? You just need to put 0 on the channels you do not need, and the value you need on the wanted channel.

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-09-16 08:37:15 -0600 )edit
1

isn't it image + cv::Scalar(blue, green, red,alpha)

sturkmen gravatar imagesturkmen ( 2015-09-16 11:53:55 -0600 )edit

maybe, I was not sure about the order of the channels :)

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-09-17 02:55:06 -0600 )edit
2
sturkmen gravatar imagesturkmen ( 2015-09-17 03:46:19 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2015-09-16 08:34:46 -0600

berak gravatar image

updated 2015-09-16 08:35:12 -0600

in c++, you can literally add/subtract Scalars, like:

img -= Scalar(0,0,57); // less red.
edit flag offensive delete link more

Comments

1

we should make a habbit of posting answers instead of comments ^_^

StevenPuttemans gravatar imageStevenPuttemans ( 2015-09-17 06:30:57 -0600 )edit
1

^^ true,true..

berak gravatar imageberak ( 2015-09-17 06:36:48 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-09-16 08:21:52 -0600

Seen: 2,254 times

Last updated: Sep 16 '15