MATLAB: Which approach for finding the DoG of the Image is convenient

Computer Vision Toolboximage analysisimage processingImage Processing Toolbox

clear;clc;close all;
image = imread('Circle.tif');
image = im2double(image(:,:,1));
Method 1
tic;
H1 = fspecial('gaussian',21,15);
H2 = fspecial('gaussian',21,20);
dog = H1 - H2;
dogFilterImage1 = conv2(image,dog,'same');
toc
figure,imshow(dogFilterImage1,[]);
%Method 2
tic;
h1 = fspecial('gaussian',21,15);
dog1 = conv2(image,h1,'same');
h2 = fspecial('gaussian',21,20);
dog2 = conv2(image,h2,'same');
dogFilterImage2 = dog2 - dog1;
toc
figure,imshow(dogFilterImage2,[]);
%Method 3
tic;
G1 = fspecial('gaussian',[1 21],15);
DoG1 = conv2(image,G1,'same');
DoG1 = conv2(DoG1,G1','same'); %h1' previously
G2 = fspecial('gaussian',[1 21],20);
DoG2 = conv2(image,G2,'same');
DoG2 = conv2(DoG2,G2','same'); % h1' previously
dogFilterImage3 = DoG2 - DoG1;
figure,imshow(dogFilterImage3,[]);
toc
output:
Elapsed time is 0.058436 seconds.
Elapsed time is 0.116693 seconds.
Elapsed time is 0.554481 seconds.
Method:1
Method 2:
Method 3:
Here, I wrote 3 different approach for finding the Difference of Gaussian(DoG). Three figures are the results of these 3 methods. Does any of the approach make any difference on the overall performance? Which method is efficient in terms of speed and performance simultaneously?
It seems that 1st method of creating DoG image is much more efficient in terms of both speed and performance, but when it comes to create DoG images in SCALE SPACE EXTREMA DETECTION(SIFT), I am confused among 3.
As suggested in this code, it uses 3rd approach. But as shown here in figure 3, I am quite hesitant to use this.

Best Answer

Well of course method 1 is best. Subtract the kernels to get a new kernel and then you have to call conv2() only once instead of twice (like in method 2). Method 3 is totally ridiculous. It's not even equivalent. You're convolving with a 1-D row vector, and then assuming that you can convolve with a 1-D column vector because the kernel is separable. However you don't do that, you convolve it with a 2D array instead, so it's not the same. Even if you did it right, it's doubtful it would be faster. 2-D convolution has very well known methods for speeding it up, and I'm very confident that those well known methods have been implemented into conv2() so there is no need to try to do it yourself by separating your kernel.
The times you have also suggest the first method is the fastest which is what you'd expect.