Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can use inRange to determine if a certain pixel is in the range R. Then you can set the pixels of Mat M to C where the output of inRange is non-zero.

You can use inRange to determine if a certain pixel is in the range R. Then you can set the pixels of Mat M to C where the output of inRange is non-zero.non-zero using setTo.

It is like (not tested/compiled):

inRange(M,RangeLow,RangeHigh,Mask);
M.setTo(C,Mask);

Another solution could the usage of LUT function. You need to define a lookup table (hence the name) which is a simple array on conversion values where you set all the pixels in the range R to C. Then you can call:

LUT(M,lookuptable,M);