How can I change brightness&contrast of image

careful ! this will only initialize the 1st (b) component of the Scalar (the g,r ones will be zero !) for 3 channel images, you need all 3, like:

ìmg + Scalar(x,y,z);