Ask Your Question

Revision history [back]

Hi!

This can be done using additions (easy to code, but not very efficient...):

 Mat imgSrc;//here is your input img
 vector<Rect> boundingBoxes;//and the bounding boxes

 Mat imgBlur, imgMask;
 blur( imgSrc, imgBlur, Size( 5, 5 ) );
 imgMask = Mat::zeros(imgSrc.size(), CV_8UC1);
 for(size_t i=0; i<boundingBoxes.size(); i++)
 {
   //Remove part of image
   rectangle(imgBlur, boundingBoxes[i], Scalar(0), CV_FILLED);
   //and create the mask
   rectangle(imgMask, boundingBoxes[i], Scalar(255), CV_FILLED);
 }

 Mat output = imgBlur.clone();
 add(imgBlur, imgSrc, output, imgMask);