Which approach for finding the DoG of the Image is convenient?
조회 수: 14 (최근 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
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.
댓글 수: 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 and Computer Vision에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!