利用Matlab中的高斯差分检测局部兴趣点

时间:2016-04-02 15:07:54

标签: matlab image-processing sift

我在Matlab中编写代码,在图像中使用DoG查找兴趣点。 这是main.m:

imTest1 = rgb2gray(imread('1.jpg'));
imTest1 = double(imTest1);

sigma = 0.6;
k = 5;
thresh = 3;

[x1,y1,r1] = DoG(k,sigma,thresh,imTest1);
%get the interest points and show it on the image with its scale
figure(1);
imshow(imTest1,[]), hold on, scatter(y1,x1,r1,'r');

功能DoG是:

function [x,y,r] = DoG(k,sigma,thresh,imTest)
x = []; y = []; r = [];
%suppose 5 levels of gaussian blur
for i = 1:k
    g{i} = fspecial('gaussian',size(imTest),i*sigma);
end
%so 4 levels of DoG
for i = 1:k-1
    d{i} = imfilter(imTest,g{i+1}-g{i});
end
%compare the current pixel in the image to the surrounding pixels (26 points),if it is the maxima/minima, this pixel will be a interest point
for i = 2:k-2
    for m = 2:size(imTest,1)-1
        for n = 2:size(imTest,2)-1

            id = 1;
            compare = zeros(1,27);
            for ii = i-1:i+1
                for mm = m-1:m+1
                    for nn = n-1:n+1
                        compare(id) = d{ii}(mm,nn);
                        id = id+1;
                    end
                end
            end

            compare_max = max(compare);
            compare_min = min(compare);

            if (compare_max == d{i}(m,n) || compare_min == d{i}(m,n))
                if (compare_min < -thresh || compare_max > thresh)
                    x = [x;m];
                    y = [y;n];
                    r = [r;abs(d{i}(m,n))];
                end
            end

        end
    end
end
end

所以有一个高斯函数,我设置的sigma是0.6。运行代码后,我发现位置不正确,并且所有兴趣点的比例看起来几乎相同。我认为我的代码应该可以工作但实际上结果不是。有谁知道问题是什么?

the test image 1.jpg the correct result for reference

0 个答案:

没有答案