本文整理汇总了C#中Complex.Select2D方法的典型用法代码示例。如果您正苦于以下问题:C# Complex.Select2D方法的具体用法?C# Complex.Select2D怎么用?C# Complex.Select2D使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Complex
的用法示例。
在下文中一共展示了Complex.Select2D方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Detect
public double[,] Detect(double[,] vectMap)
{
Complex[,] cMap = new Complex[width, height];
Complex[,] V_r = new Complex[width, height];
double[,] str = new double[width, height];
for (int x = 1; x < width - 1; ++x )
{
for (int y = 1; y < height - 1; ++y)
{
cMap[x, y] = new Complex(Math.Sin(2*vectMap[x, y]), Math.Cos(2*vectMap[x, y]));
}
}
V_r = Regularize(cMap);
var newField = V_r.Select2D(x => x.Phase / 2);
str = Strengthen(V_r);
return str;
}
示例2: SearchMinutiae
private static List<Minutia> SearchMinutiae(Complex[,] psi, Complex[,] lsEnhanced, Complex[,] ps)
{
Stopwatch sw = new Stopwatch();
sw.Start();
var size = new Size(psi.GetLength(0), psi.GetLength(1));
for (int x = 0; x < size.Width; x++)
{
for (int y = 0; y < size.Height; y++)
{
if (psi[x, y].Magnitude < tauPS) psi[x, y] = 0;
}
}
var grid = new int[psi.GetLength(0), psi.GetLength(1)];
var maxs = psi.Select2D((x, row, column) =>
{
Point maxP = new Point();
double maxM = tauPS;
for (int dRow = -NeighborhoodSize / 2; dRow <= NeighborhoodSize / 2; dRow++)
{
for (int dColumn = -NeighborhoodSize / 2; dColumn <= NeighborhoodSize / 2; dColumn++)
{
var correctRow = row + dRow;
var correctColumn = column + dColumn;
if (correctRow > 9 && correctColumn > 9
&& correctColumn < psi.GetLength(1) - 10 && correctRow < psi.GetLength(0) - 10)
{
var value = psi[correctRow, correctColumn];
if (value.Magnitude > maxM)
{
maxM = value.Magnitude;
maxP = new Point(correctRow, correctColumn);
}
}
}
}
if (!maxP.IsEmpty)
grid[maxP.X, maxP.Y]++;
return maxP;
});
Dictionary<Point, int> responses = new Dictionary<Point, int>();
foreach (var point in maxs)
{
if (!responses.ContainsKey(point)) responses[point] = 0;
responses[point]++;
}
ImageHelper.SaveArrayAsBinary(grid, "C:\\temp\\grid.bin");
var orderedListOfCandidates =
responses.Where(x => x.Value >= 20 && x.Key.X > 0 && x.Key.Y > 0 && x.Key.X < psi.GetLength(0) - 1 && x.Key.Y < psi.GetLength(1) - 1)
.OrderByDescending(x => x.Value)
.Select(x => x.Key)
.Where(x => psi[x.X, x.Y].Magnitude >= tauPS);
List<Minutia> minutiae = new List<Minutia>();
int cnt = 0;
foreach (var candidate in orderedListOfCandidates)
{
int count = 0;
double sum = 0;
for (int dx = -ringOuterRadius; dx <= ringOuterRadius; dx++)
{
for (int dy = -ringOuterRadius; dy <= ringOuterRadius; dy++)
{
if (Math.Abs(dx) < ringInnerRadius && Math.Abs(dy) < ringInnerRadius) continue;
count++;
int xx = candidate.X + dx;
if (xx < 0) xx = 0;
if (xx >= size.Width) xx = size.Width - 1;
int yy = candidate.Y + dy;
if (yy < 0) yy = 0;
if (yy >= size.Height) yy = size.Height - 1;
sum += lsEnhanced[xx, yy].Magnitude;
}
}
if (sum / count > tauLS)
{
cnt++;
if (!minutiae.Any(pt => (pt.X - candidate.X) * (pt.X - candidate.X) + (pt.Y - candidate.Y) * (pt.Y - candidate.Y) < 30))
minutiae.Add(new Minutia() { X = candidate.X, Y = candidate.Y, Angle = ps[candidate.X, candidate.Y].Phase });
}
}
var endList = minutiae.OrderByDescending(x =>
ps[x.X, x.Y].Magnitude)
.Take(MaxMinutiaeCount)
.ToList();
sw.Stop();
return endList;
}