有人可以向我解释Feature2DToolbox.VoteForUniqueness如何工作吗?
这是使用它的源代码:
BruteForceMatcher<float> matcher = new BruteForceMatcher<float>(DistanceType.L2);
matcher.Add(modelfeature);
indices = new Matrix<int>(destfeature.Rows, 2);
dist = new Matrix<float>(destfeature.Rows, 2);
matcher.KnnMatch(destfeature, indices, dist, 2, null);
mask = new Matrix<byte>(dist.Rows, 1);
mask.SetValue(255);
Features2DToolbox.VoteForUniqueness(dist, 0.8, mask);
我想做一本手册:
indices = new Matrix<int>(destfeature.Rows, 2);
dist = new Matrix<float>(destfeature.Rows, 2);
for (int i = 0; i < destfeature.Rows; i++)
{
dist[i, 0] = float.MaxValue;
dist[i, 1] = float.MaxValue;
indices[i, 0] = -1;
indices[i, 1] = -1;
for (int j = 0; j < modelfeature.Rows; j++)
{
float temp = 0;
for (int k = 0; k < 128; k++)
{
temp = temp +(float) Math.Pow(modelfeature[j, k] - destfeature[i, k], 2.0);
}
temp =(float) Math.Sqrt(temp);
if (temp < dist[i, 0])
{
dist[i, 1] = dist[i, 0];
indices[i, 1] = indices[i, 0];
dist[i, 0] = temp;
indices[i, 0] = j;
}
else if (temp < dist[i, 1])
{
dist[i, 1] = temp;
indices[i, 1] = j;
}
}
}
mask = new Matrix<byte>(dist.Rows, 1);
for (int i = 0; i < dist.Rows; i++)
{
if (dist[i, 0] < dist[i, 1] * 0.8)
{
mask[i, 0] = 255;
}
else
{
mask[i, 0] = 0;
}
}
在我犯错之前已经编辑过的是,我将dist [i,1]除以dist [i,0],如果大于0.8,则为true。
“ VoteForUniqueness”的想法是过滤不明确的匹配。假设您想将图像A的点与图像B的点进行匹配。
下面是它的工作原理 :
值得一提的是,当我们谈论最近的邻居和距离时,我们谈论的是点的特征(而不是位置)之间的距离。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句