通过使用 matlab 应用 Gabor 方程创建 Gabor 滤波器 [英] Create a Gabor filter by applying Gabor equation using matlab

查看:21
本文介绍了通过使用 matlab 应用 Gabor 方程创建 Gabor 滤波器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I tried to create a Gabor Filter. We all know that this kind of filter is more complex than any other filters because it is characterized by more complex features such as having different scales and orientations. The equation of Gabor filter is:

要创建具有特定比例和方向的 Gabor 过滤器,wikipedia 给出了我们一个简单的matlab代码:

To create such a Gabor filter with a specific scale and direction, the wikipedia gives to us a simple matlab code about that:

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 是什么..

I want to know if this code is correct. I notice that the code above didn't respond exactly to the equation of Gabor filter. For example: in the code, we have :sigma_x=sigma and sigma_y=sigma/gamma ... and we have gb=exp(-.5*(x_theta.....)). I didn't understand what is the 5 in the equation..

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

Is the matlab code written above respond correctly to the equation of the Gabor filter?? please i need your opinion and if possible to optimize the code if it is not correct.

任何帮助将不胜感激.

推荐答案

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

Replace below line in your code:

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.

I replace the cos with sin in above matlab code.

这篇关于通过使用 matlab 应用 Gabor 方程创建 Gabor 滤波器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆