OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Wed, 01 Mar 2017 04:46:39 -0600Gaussian kernel in OpenCV to generate multiple scaleshttp://answers.opencv.org/question/130747/gaussian-kernel-in-opencv-to-generate-multiple-scales/ I want to implement an OpenCV version of [VL_PHOW()][1] ([matlab src code][2]) from VLFeat. In few words, it's dense SIFT with multiple scales (increasing SIFT descriptor bin size) to make it scale invariant.
However, the authors suggests to apply a Gaussian kernel to improve the results. In paritcular, the `Magnif` parameter describe it:
> Magnif 6 The image is smoothed by a Gaussian kernel of standard
> deviation SIZE / MAGNIF. Note that, in the standard SIFT descriptor,
> the magnification value is 3; here the default one is 6 as it seems to
> perform better in applications.
And this is the relevant matlab code:
% smooth the image to the appropriate scale based on the size
% of the SIFT bins
sigma = opts.sizes(si) / opts.magnif ;
ims = vl_imsmooth(im, sigma) ;
My question is: how can I implement this in OpenCV? The equivalent function in OpenCV seems to be [GaussianBlur][3], but I can't figure out how to represent the code above in terms of this function.
[1]: http://www.vlfeat.org/matlab/vl_phow.html
[2]: https://github.com/vlfeat/vlfeat/blob/master/toolbox/sift/vl_phow.m
[3]: http://docs.opencv.org/3.0-beta/modules/imgproc/doc/filtering.html#gaussianblurWed, 01 Mar 2017 04:14:59 -0600http://answers.opencv.org/question/130747/gaussian-kernel-in-opencv-to-generate-multiple-scales/Comment by LBerger for <p>I want to implement an OpenCV version of <a href="http://www.vlfeat.org/matlab/vl_phow.html">VL_PHOW()</a> (<a href="https://github.com/vlfeat/vlfeat/blob/master/toolbox/sift/vl_phow.m">matlab src code</a>) from VLFeat. In few words, it's dense SIFT with multiple scales (increasing SIFT descriptor bin size) to make it scale invariant.</p>
<p>However, the authors suggests to apply a Gaussian kernel to improve the results. In paritcular, the <code>Magnif</code> parameter describe it:</p>
<blockquote>
<p>Magnif 6 The image is smoothed by a Gaussian kernel of standard
deviation SIZE / MAGNIF. Note that, in the standard SIFT descriptor,
the magnification value is 3; here the default one is 6 as it seems to
perform better in applications.</p>
</blockquote>
<p>And this is the relevant matlab code:</p>
<pre><code>% smooth the image to the appropriate scale based on the size
% of the SIFT bins
sigma = opts.sizes(si) / opts.magnif ;
ims = vl_imsmooth(im, sigma) ;
</code></pre>
<p>My question is: how can I implement this in OpenCV? The equivalent function in OpenCV seems to be <a href="http://docs.opencv.org/3.0-beta/modules/imgproc/doc/filtering.html#gaussianblur">GaussianBlur</a>, but I can't figure out how to represent the code above in terms of this function. </p>
http://answers.opencv.org/question/130747/gaussian-kernel-in-opencv-to-generate-multiple-scales/?comment=130750#post-id-130750your link is about 3.0-beta you should update it to 3.2. Now if you scroll link page you will find getGaussianKernel with a link in last doc [here](http://docs.opencv.org/master/d4/d86/group__imgproc__filter.html#gac05a120c1ae92a6060dd0db190a61afa). I think it is what you need.
All docs are [here](http://docs.opencv.org/)Wed, 01 Mar 2017 04:22:56 -0600http://answers.opencv.org/question/130747/gaussian-kernel-in-opencv-to-generate-multiple-scales/?comment=130750#post-id-130750Comment by LBerger for <p>I want to implement an OpenCV version of <a href="http://www.vlfeat.org/matlab/vl_phow.html">VL_PHOW()</a> (<a href="https://github.com/vlfeat/vlfeat/blob/master/toolbox/sift/vl_phow.m">matlab src code</a>) from VLFeat. In few words, it's dense SIFT with multiple scales (increasing SIFT descriptor bin size) to make it scale invariant.</p>
<p>However, the authors suggests to apply a Gaussian kernel to improve the results. In paritcular, the <code>Magnif</code> parameter describe it:</p>
<blockquote>
<p>Magnif 6 The image is smoothed by a Gaussian kernel of standard
deviation SIZE / MAGNIF. Note that, in the standard SIFT descriptor,
the magnification value is 3; here the default one is 6 as it seems to
perform better in applications.</p>
</blockquote>
<p>And this is the relevant matlab code:</p>
<pre><code>% smooth the image to the appropriate scale based on the size
% of the SIFT bins
sigma = opts.sizes(si) / opts.magnif ;
ims = vl_imsmooth(im, sigma) ;
</code></pre>
<p>My question is: how can I implement this in OpenCV? The equivalent function in OpenCV seems to be <a href="http://docs.opencv.org/3.0-beta/modules/imgproc/doc/filtering.html#gaussianblur">GaussianBlur</a>, but I can't figure out how to represent the code above in terms of this function. </p>
http://answers.opencv.org/question/130747/gaussian-kernel-in-opencv-to-generate-multiple-scales/?comment=130754#post-id-130754ksize is filter size and it is not sigma Example kernel size can be 3x3 or 5x5 or 21x21 with sigma =1. It will change accuracy. Of course 21x21 is better than 3x3 but sometime 5x5 is enough. You will have to decide.Wed, 01 Mar 2017 04:46:39 -0600http://answers.opencv.org/question/130747/gaussian-kernel-in-opencv-to-generate-multiple-scales/?comment=130754#post-id-130754Comment by lovaj for <p>I want to implement an OpenCV version of <a href="http://www.vlfeat.org/matlab/vl_phow.html">VL_PHOW()</a> (<a href="https://github.com/vlfeat/vlfeat/blob/master/toolbox/sift/vl_phow.m">matlab src code</a>) from VLFeat. In few words, it's dense SIFT with multiple scales (increasing SIFT descriptor bin size) to make it scale invariant.</p>
<p>However, the authors suggests to apply a Gaussian kernel to improve the results. In paritcular, the <code>Magnif</code> parameter describe it:</p>
<blockquote>
<p>Magnif 6 The image is smoothed by a Gaussian kernel of standard
deviation SIZE / MAGNIF. Note that, in the standard SIFT descriptor,
the magnification value is 3; here the default one is 6 as it seems to
perform better in applications.</p>
</blockquote>
<p>And this is the relevant matlab code:</p>
<pre><code>% smooth the image to the appropriate scale based on the size
% of the SIFT bins
sigma = opts.sizes(si) / opts.magnif ;
ims = vl_imsmooth(im, sigma) ;
</code></pre>
<p>My question is: how can I implement this in OpenCV? The equivalent function in OpenCV seems to be <a href="http://docs.opencv.org/3.0-beta/modules/imgproc/doc/filtering.html#gaussianblur">GaussianBlur</a>, but I can't figure out how to represent the code above in terms of this function. </p>
http://answers.opencv.org/question/130747/gaussian-kernel-in-opencv-to-generate-multiple-scales/?comment=130752#post-id-130752@LBerger thanks for your answer. However, I don't understand what the `ksize` parameter should be. Besides, is it correct that the matlab code above can be replicated using `cv::GaussianBlur(in, out, cv::Size(), sigma)` ?Wed, 01 Mar 2017 04:40:21 -0600http://answers.opencv.org/question/130747/gaussian-kernel-in-opencv-to-generate-multiple-scales/?comment=130752#post-id-130752