Ask Your Question
1

how blury the background apart from ROI

asked 2014-11-29 01:30:19 -0600

helxsz gravatar image

updated 2015-09-19 11:25:48 -0600

I have a road scene picture, and I can detect the vehicles on the road. What I want to do is to blur the whole picture except the vehicle detection areas, my solution is firstly I create a empty Mat and crop the vehicle detection area into the empty Mat, and secondly blur the whole picture, now the problem is how to combine the blury picture with the vehicle parts ?

image description

edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted
2

answered 2014-11-30 13:56:09 -0600

You can just copy the vehicles using cv::copy. If A is your full (unblurred Image), B is the blurred version, and a car region is defined from col c_1 to c_2 and row range r_1,r_2, you can copy the car by

A.rowrange(r_1,r_2).colrange(c_1,c_2).copyTo(B.rowrange(r_1,r_2).colrange(c_1,c_2))
edit flag offensive delete link more
2

answered 2014-11-30 14:34:19 -0600

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);
edit flag offensive delete link more
2

answered 2014-11-30 23:02:53 -0600

updated 2014-12-01 10:26:02 -0600

1-You have localize the external mask of all vehicles.

2-Apply radial low pass filter(in the edge,the sigma is desired value & in the center of mask sigma is zero) on mask region of each vehicles.

3-Apply low pass filter on the whole image apart from vehicles mask region.

4-Copy the vehicles region from the radial low pass image in to destination low pass image.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-11-29 01:30:19 -0600

Seen: 907 times

Last updated: Dec 01 '14