フィルターのクリア

Which approach for finding the DoG of the Image is convenient?

10 ビュー (過去 30 日間)
Jay
Jay 2016 年 3 月 14 日
コメント済み: Image Analyst 2019 年 10 月 29 日
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
Image Analyst 2016 年 3 月 14 日
image is a built-in function. You should not use it as the name for your variable.
Jay
Jay 2016 年 3 月 14 日
I know.I would take care of this thing. Thanks for letting me know.

サインインしてコメントする。

採用された回答

Image Analyst
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
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
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 ExchangeImage Processing Toolbox についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by