Ask Your Question

Revision history [back]

May be like this using mask and function setTo :

Mat im=Mat::zeros(512,512,CV_8UC1);
Rect r(200,200,100,100);
Mat mask=Mat::zeros(512,512,CV_8UC1);
mask(r)=255;

bitwise_not(mask,mask);
im.setTo(255,mask);
imshow("mask ",im);
waitKey();