任何人都可以告诉我如何使用RANSAC算法在两个具有一定部分重叠的图像中选择共同的特征点?问题来自基于功能的图像缝制。
alt text alt text

有帮助吗?

解决方案

几年前,我实施了一个图像史基。关于Wikipedia的Ransac的文章很好地描述了Algortihm将军。

当使用RANSAC进行基于功能的图像匹配时,您想要的是找到最能将第一个图像转换为第二张图像的转换。这将是Wikipedia文章中描述的模型。

如果您已经获得了这两个图像的功能,并且已经找到了第一个图像中最佳匹配项中的哪些功能,这些功能将在第二张图像中使用,则将使用RANSAC。

The input to the algorithm is:
n - the number of random points to pick every iteration in order to create the transform. I chose n = 3 in my implementation.
k - the number of iterations to run
t - the threshold for the square distance for a point to be considered as a match
d - the number of points that need to be matched for the transform to be valid
image1_points and image2_points - two arrays of the same size with points. Assumes that image1_points[x] is best mapped to image2_points[x] accodring to the computed features.

best_model = null
best_error = Inf
for i = 0:k
  rand_indices = n random integers from 0:num_points
  base_points = image1_points[rand_indices]
  input_points = image2_points[rand_indices] 
  maybe_model = find best transform from input_points -> base_points

  consensus_set = 0
  total_error = 0
  for i = 0:num_points
    error = square distance of the difference between image2_points[i] transformed by maybe_model and image1_points[i]
    if error < t
      consensus_set += 1
      total_error += error

  if consensus_set > d && total_error < best_error
    best_model = maybe_model
    best_error = total_error

最终结果是最能将image2中的点转换为image1中的转换,这在缝合时非常适合您想要的内容。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top