我正在使用Accord.Net的SURF功能比较两个图像。在人眼中,这两个图像极为相似:
我通过以下代码运行这些图像(改编自here):
Bitmap one = (Bitmap)Bitmap.FromFile(@"one.png");
if ( (one.Width > 256) && (one.Height > 256))
{
double shrink = Math.Min(one.Width / 256.0, one.Height / 256.0);
one = new Bitmap(one, new Size((int)(one.Width / shrink + 0.5), (int)(one.Height / shrink + 0.5)));
}
Bitmap two = (Bitmap)Bitmap.FromFile(@"two.jpg");
if ((two.Width > 256) && (two.Height > 256))
{
double shrink = Math.Min(two.Width / 256.0, two.Height / 256.0);
two = new Bitmap(two, new Size((int)(two.Width / shrink + 0.5), (int)(two.Height / shrink + 0.5)));
}
var surf = new SpeededUpRobustFeaturesDetector(threshold: 0.0002f, octaves: 5, initial: 2);
IEnumerable<SpeededUpRobustFeaturePoint> onePoints = surf.Transform(one);
IEnumerable<SpeededUpRobustFeaturePoint> twoPoints = surf.Transform(two);
KNearestNeighborMatching matcher = new KNearestNeighborMatching(5);
var matchPoints = matcher.Match(onePoints, twoPoints);
我得到的是第一张图片中的329个特征点和第二张图片中的354个点,并且匹配集具有两个向量,每个向量的大小均为219。得出的匹配百分比仅为66%。鉴于这两张图片本质上是相同的,我希望匹配百分比要好得多。
编辑
我现在正在绘制matchPoints,假设matchPoints [0] [n]是第一张图片中与第二张图片中的matchPoints 1 [n]相匹配的点。结果不是很好:
我会相信大多数匹配项,但是有很多地方线的对角线告诉我这些匹配项不是“有效”