Pregunta

Puede alguien por favor me muestran cómo utilizar el algoritmo RANSAC para seleccionar puntos de característica común en dos imágenes que tienen una cierta porción de solapamiento? El problema salió de función basada costura de la imagen.
texto alternativo text alt

¿Fue útil?

Solución

Me implementa una imagen grapadora un par de años atrás. El artículo sobre RANSAC en la Wikipedia describe así la algortihm general.

Cuando se utiliza para RANSAC característica basada comparación de imágenes, lo que quiere es encontrar la transformada la primera imagen que mejor se transforma a la segunda imagen. Este sería el modelo descrito en el artículo de Wikipedia.

Si ya tiene sus características tanto de imágenes y han encontrado que cuenta en la primera imagen que cuenta con mejores partidos en la segunda imagen, RANSAC se utilizaría algo como esto.

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

El resultado final es la transformación que los mejores tranforms puntos en imagen2 imagen1 a, que es lo que quiere exacly al coser.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top