帮助:将gabor formola转换为C族语言 [英] Help:convert gabor formola to C family Language
本文介绍了帮助:将gabor formola转换为C族语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
任何人都可以将gabor公式转换为C#中的代码吗?
以下页面解释了该公式:
Gabor过滤器
Hi
Can anybody convert gabor formula to code in C#
the following Page explain the formula:
Gabor filter
推荐答案
我相信这就是你的身份之后.
公平警告:
-我还没有运行代码
-在阅读此问题之前,我什至从未听说过MATLAB
I believe this is what you are after.
FAIR WARNING:
- i haven''t run thus code
- i had never even heard of MATLAB before reading this question
public IDictionary<Point, double> gaborFn(double sigma, double theta, double lambda, double psi, double gamma)
{
IDictionary<Point,double> result = new Dictionary<Point,double> ();
double sigma_x = sigma;
double sigma_y = sigma/gamma;
//Bounding box
int nstds = 3;
double xmax = Math.Max(Math.Abs(nstds*sigma_x*Math.Cos(theta)),Math.Abs(nstds*sigma_y*Math.Sin(theta)));
xmax = Math.Ceiling(Math.Max(1,xmax));
double ymax = Math.Max(Math.Abs(nstds*sigma_x*Math.Sin(theta)),Math.Abs(nstds*sigma_y*Math.Cos(theta)));
ymax = Math.Ceiling(Math.Max(1,ymax));
double xmin = -xmax;
double ymin = -ymax;
for (int x = (int)xmin; x <=xmax;x++)
{
for (int y = (int)ymin; x <= ymax; x++)
{
// Rotation
double x_theta = x * Math.Cos(theta) + y * Math.Sin(theta);
double y_theta = -x * Math.Sin(theta) + y * Math.Cos(theta);
double gb = 1 / (2 * Math.PI * sigma_x * sigma_y) * Math.Exp(-.5 * (Math.Pow(x_theta, 2) / Math.Pow(sigma_x, 2) + Math.Pow(y_theta, 2) / Math.Pow(sigma_y, 2))) * Math.Cos(2 * Math.PI / lambda * x_theta + psi);
result.Add(new Point(x, y), gb);
}
}
return result;
}
这篇关于帮助:将gabor formola转换为C族语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文