8

I am new to Image Processing, and in my experiment I am having difficulty with Difference of Gaussians. Various implementation were given to me but I don't understand them and their parameters.

Here are my formulas

enter image description here

Should I implement this filtering myself, or is there an existing function defined for this? Of course with all parameters which are like in link. I will need to play with parameters and produce different images.

buruzaemon
  • 3,847
  • 1
  • 23
  • 44
Sedat KURT
  • 478
  • 4
  • 9
  • 20

1 Answers1

16

You could Gaussian filter an image twice with two different std. dev. and just subtract them, would be the same as using the combined filter.

k = 10;
sigma1 =  0.5;
sigma2 = sigma1*k;

hsize = [3,3];

h1 = fspecial('gaussian', hsize, sigma1);
h2 = fspecial('gaussian', hsize, sigma2);

gauss1 = imfilter(img,h1,'replicate');
gauss2 = imfilter(img,h2,'replicate');

dogImg = gauss2 - gauss1;
David Nilosek
  • 1,422
  • 9
  • 13
  • You have a typo in your code. You define two different h1, but the second one should be h2. – thejinx0r Dec 09 '15 at 18:35
  • 4
    To be consistent with the difference-of-Gaussians approach from D.G. Lowe (originator of the Scale-Invariant Features Transform or SIFT), the last line should be `dogImg = gauss2 - gauss1;` – Jim Peters Aug 24 '16 at 15:55
  • It is very important to pick a `hsize` large enough to contain the Gaussian. A 3x3 filter is never large enough for a Gaussian, especially one with a sigma of 5 like `h2`. See [this old blog post of mine](https://www.crisluengo.net/archives/150/) for more information. – Cris Luengo Apr 22 '22 at 08:10