Parallelize chain of Gaussian Blurs

此生再无相见时 提交于 2019-12-11 10:16:06

问题


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?

This answer let me think that it's possible, but I can't understand how I can implement this:

Convolve filters If you apply multiple filters on the same image consecutively, like a gaussian blur, then a Gabor filter, you can combine them together. Make all filters the same size and convolve them. Then apply the result on the image. Math says the effect will be identical with the previous combination


回答1:


This is possible (you can parallelize). I had exactly the same issue, and solved it this way (see my answer to that problem, with python code).

https://dsp.stackexchange.com/questions/667/image-pyramid-without-decimation/55654#55654



来源:https://stackoverflow.com/questions/43163337/parallelize-chain-of-gaussian-blurs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!