Which approach for finding the DoG of the Image is convenient?
7 次查看(过去 30 天)
显示 更早的评论
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/157704/image.png)
Method 2:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/157705/image.png)
Method 3:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/157706/image.png)
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.
2 个评论
Image Analyst
2016-3-14
image is a built-in function. You should not use it as the name for your variable.
采纳的回答
Image Analyst
2016-3-14
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.
7 个评论
Sameer Mahmood
2019-10-28
1.n = (6*sigma_1+ 1) for 1st level.
2.n = (6*sigma_2+ 1) for 2nd level.
as mentioned here that the value of n are different and impossible to subtract them for DoG filter.
So, how do we choose an appropriate size for any two sigmas given?
Because randomly assissgning a value between 'n' for first level and second level dont sound right.
Image Analyst
2019-10-29
"as mentioned here" -- as mentioned where???
What is the purpose of your n variable?
And who says that you can't subtract two matrices of the same size (rows and columns) containing Gaussians with different sigmas? Why do you say it's impossible???
The way I determine the best two sigmas is to have a double for loop where I try them all. Then look at the resulting images and determine which one you think works best. It's pretty much a subjective call.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!