Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

yes, you can do that, but you have to be careful with the type there.

if you read an image with imread(), the depth will be uchar and it's values in [0..255] range.

operations like adding or multiplying will get saturated, meaning, that 130*2 will be 255, not 260, and 17 *-1 will be 0, not -17

if you want to avoid the saturation, you have to convert your images to CV_32S (integer) or CV_32F (float).

then note another pitfall here:

A * 5

will be translated internally as:

A * Scalar(5,0,0,0)

this will only multiply the 1st channel with 5, all others(if they exist) with 0 !!

so, for multi-channel images, you need to explicitly write:

 A * Scalar(5,5,5)

yes, you can do that, but you have to be careful with the type there.

if you read an image with imread(), the depth will be uchar and it's values in [0..255] range.

operations like adding or multiplying will get saturated, meaning, that 130*2 will be 255, not 260, and 17 *-1 will be 0, not -17

if you want to avoid the saturation, you have to convert your images to CV_32S (integer) or CV_32F (float).

then note another pitfall here:

A * 5

will be translated internally as:

A * Scalar(5,0,0,0)

this will only multiply the 1st channel with 5, all others(if they exist) with 0 !!

so, for multi-channel images, you need to explicitly write:

 A * Scalar(5,5,5)