I have the code (OpenSURF C#, IPoint struct used), it calculates SURF matches for two images:
var surfEngine = new EngineSURF();
points[0] = surfEngine.GetPoints(images[0]).ToList();
points[1] = surfEngine.GetPoints(images[1]).ToList();
points[2] = surfEngine.GetPoints(images[2]).ToList();
points[3] = surfEngine.GetPoints(images[3]).ToList();
var match1 = surfEngine.GetMatches(points[0], points[1]).ToArray();
var match2 = surfEngine.GetMatches(points[0], points[2]).ToArray();
var match3 = surfEngine.GetMatches(points[0], points[3]).ToArray();
outBmps[0] = surfEngine.PaintSURF(new Bitmap(images[0]), new Bitmap(images[1]), match1);
outBmps[1] = surfEngine.PaintSURF(new Bitmap(images[0]), new Bitmap(images[2]), match2);
outBmps[2] = surfEngine.PaintSURF(new Bitmap(images[0]), new Bitmap(images[3]), match3);
var path = Path.GetDirectoryName(images[0]) ?? string.Empty;
Checks.StringIsNotNull(path);
if(outBmps[0] != null) outBmps[0].Save(Path.Combine(path,"result0_1.png"), ImageFormat.Png);
if (outBmps[1] != null) outBmps[1].Save(Path.Combine(path, "result0_2.png"), ImageFormat.Png);
if (outBmps[2] != null) outBmps[2].Save(Path.Combine(path, "result0_3.png"), ImageFormat.Png);
And I have next matches:
1) Best matches
2) Wrong matches
3) Wrong matches
How I can filter wrong (2, 3) matches with RANSAC? Have any sample code? Thanks!
Accord.Imaging allows find SURF features and estimate points using RANSAC.
var correlationPoints1 = matches[0];
var correlationPoints2 = matches[1];
var ransac = new RansacHomographyEstimator(0.10, 0.99);
var homography = ransac.Estimate(correlationPoints1, correlationPoints2);
var inliers1 = correlationPoints1.Submatrix(ransac.Inliers);
var inliers2 = correlationPoints2.Submatrix(ransac.Inliers);
var result = new IntPoint[][]
{
inliers1,
inliers2
};