我尝试创建一个 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=sigma
和 sigma_y=sigma/gamma
... 我们有 gb=exp(-.5* (x_theta.....))
。我不明白等式中的 5
是什么..
上面写的matlab代码是否正确响应了Gabor滤波器的方程??我需要您的意见,如果代码不正确,请尽可能优化它。
我们将不胜感激。
最佳答案
在您的代码中替换以下行:
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。
关于image-processing - 通过使用 matlab 应用 Gabor 方程创建 Gabor 滤波器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20147891/