Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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?