下面是我们用的MATLAB程序,计算SIGMA从0.1到2.5步长为0.1的LoG对应的DoG:
tab = [];
for sigma = 0.1:0.1:2.5;
Hlog = fspecial('log', [15 15], sigma);
bestSigma1 = -1;
bestSigma2 = -1;
bestResult = 100000000;
for sigma1 = 0.01:0.001:4*sigma
for sigma2 = sigma1:0.001:4*sigma
g1 = fspecial('gaussian', [15 15], sigma1 );
g2 = fspecial('gaussian', [15 15], sigma2 );
g = g2 - g1;
d = sum(sum(abs(Hlog-g)));
if( d < bestResult )
bestResult = d;
bestSigma1 = sigma1;
bestSigma2 = sigma2;
bestFilter = g;
end
end
end
tab = [tab; sigma bestSigma1 bestSigma2]
end
看懂了吧,就是用穷举法列出一大堆的DoG filter kernel, 然后从中选一个最接近那个LoG filter kernel的.
图龙说的好:
------ that's why we need Matlab!