Parallelize chain of blurs

I have this code (revisited version of this):

void HessianDetector::detectOctaveKeypoints(const Mat &firstLevel, ...)
{
vector<Mat> blurs (par.numberOfScales+3, Mat());
blurs[1] = firstLevel;
for (int i = 1; i < par.numberOfScales+2; i++){
float sigma = par.sigmas[i]* sqrt(sigmaStep * sigmaStep - 1.0f);
blurs[i+1] = gaussianBlur(blurs[i], sigma);
}
...


Where:

Mat gaussianBlur(const Mat input, const float sigma)
{
Mat ret(input.rows, input.cols, input.type());
int size = (int)(2.0 * 3.0 * sigma + 1.0); if (size % 2 == 0) size++;
GaussianBlur(input, ret, Size(size, size), sigma, sigma, BORDER_REPLICATE);
return ret;
}


So, as you can see, each blurs[i+1] depends on blurs[i], so it cannot be parallelized. My question is: is there an equivalent way to obtain the same result but using firstLevel instead of blurs[i]? So it should so look something like:

for (int i = 1; i < par.numberOfScales+2; i++){
float sigma = //something;
blurs[i+1] = gaussianBlur(firstLevel, sigma);
}


Is it possible?

edit retag close merge delete

Sort by » oldest newest most voted

Applying multiple, successive gaussian blurs to an image has the same effect as applying a single, larger gaussian blur, whose radius is the square root of the sum of the squares of the blur radii that were actually applied. For example, applying successive gaussian blurs with radii of 6 and 8 gives the same results as applying a single gaussian blur of radius 10, since sqrt {6^{2}+8^{2}}=10. Because of this relationship, processing time cannot be saved by simulating a gaussian blur with successive, smaller blurs — the time required will be at least as great as performing the single large blur.

more

@Tetragramm Thanks for your answer! Since (as you can see) I'm not expert with gaussian blurs, the radius is sigma in the opencv function, right?

( 2017-04-02 04:19:00 -0500 )edit

Ah, yes, sorry. So sigma blur1 then blur2 = sqrt(sigma1^2+sigma2^2)

( 2017-04-02 08:35:59 -0500 )edit

@Tegragramm could please give a look at this question?

( 2017-04-14 08:41:03 -0500 )edit