【问题标题】:Create a Gabor filter by applying Gabor equation using matlab通过使用 matlab 应用 Gabor 方程创建 Gabor 滤波器
【发布时间】:2013-12-07 12:17:32
【问题描述】:

我尝试创建一个 Gabor 过滤器。我们都知道这种过滤器比任何其他过滤器都更复杂,因为它具有更复杂的特征,例如具有不同的尺度和方向。 Gabor滤波器方程为:

要创建这样一个具有特定比例和方向的 Gabor 滤波器,wikipedia 为我们提供了一个简单的 matlab 代码:

sigma_x = sigma;
sigma_y = sigma/gamma;

nstds = 3;
xmax = max(abs(nstds*sigma_x*cos(theta)),abs(nstds*sigma_y*sin(theta)));
xmax = ceil(max(1,xmax));
ymax = max(abs(nstds*sigma_x*sin(theta)),abs(nstds*sigma_y*cos(theta)));
ymax = ceil(max(1,ymax));
xmin = -xmax; ymin = -ymax;
[x,y] = meshgrid(xmin:xmax,ymin:ymax);


x_theta=x*cos(theta)+y*sin(theta);
y_theta=-x*sin(theta)+y*cos(theta);

gb= exp(-.5*(x_theta.^2/sigma_x^2+y_theta.^2/sigma_y^2)).*cos(2*pi/lambda*x_theta+psi);

我想知道这段代码是否正确。我注意到上面的代码并没有完全响应 Gabor 滤波器的方程。例如:在代码中,我们有:sigma_x=sigmasigma_y=sigma/gamma ... 我们有 gb=exp(-.5*(x_theta.....))。我不明白等式中的5 是什么..

上面写的matlab代码是否正确响应了Gabor滤波器的方程??请我需要您的意见,如果代码不正确,请尽可能优化代码。

任何帮助将不胜感激。

【问题讨论】:

    标签: image-processing computer-vision matlab


    【解决方案1】:

    在您的代码中替换以下行:

    gb= exp(-.5*(x_theta.^2/sigma_x^2+y_theta.^2/sigma_y^2)).*cos(2*pi/lambda*x_theta+psi);
    

    我在上面的matlab代码中用sin替换了cos。

    【讨论】:

    • Désolé,我编辑了我的问题,这不是罪过 :) 顺便谢谢你的回答 :) ,, 但是为什么是 exp(-.5 ... ,, 为什么是 5 ? ?
    • 以及为什么 sigma_x = sigma;和 sigma_y = sigma/gamma; ,,, 代码对方程的响应是否正确?
    • 1/2 = 0.5,a/c +b/c可以写成(a+b)/2,反之亦然。所以 (x^2+gamma^2*y^2)/2*sigma^2 可以写成 0.5 *( (x^2/sigma^2) + (y^2*gama^2/sigma^2) )
    • 你还有问题吗?
    • 是的,我明白了,非常感谢:),但是为什么它们将有效宽度 sigma_y 表示为 sigma/gamma ?你知道为什么吗?
    【解决方案2】:

    公式为 exp(-(...) / (2*sigma^2) )。不是吗? 所以 1/2 = 0.5 = .5

    【讨论】:

    • 谢谢你的回答:-)
    【解决方案3】:

    您现在可以使用图像处理工具箱中的gabor 函数创建一个 Gabor 滤波器组,并且可以使用imgaborfilt 将其应用于图像。

    【讨论】:

    • 啊哈太棒了!他们现在变得如此简单
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-11
    • 2011-07-04
    • 1970-01-01
    • 2023-03-19
    • 1970-01-01
    • 2012-02-14
    相关资源
    最近更新 更多