1. setTo
Mat orig = imread("in.jpg");
Mat test = orig.clone();
test.setTo(Scalar::all(255), mask1ch);
assign the pixel value to 255 when its corresponding pixel is 1 in mask1ch(将掩膜上的元素置为指定的元素值)
2. copyTo
void copyTo( OutputArray m ) const;
void copyTo( OutputArray m, InputArray mask ) const;
3. convertTo
mask.convertTo(inv_mask, CV_8UC3, -1.0, 255.0);
// inverse the mask matrix means I_new(x,j) = 255-1*I(x,j).
This is the model c = a* I + beta. at opencv the convertTo can not change the channel number