bbrister / SIFT3D

Analogue of the scale-invariant feature transform (SIFT) for three-dimensional images. Includes an image processing and linear algebra library with feature matching and RANSAC regression. Also includes IO functions supporting a variety of image formats.
MIT License
134 stars 47 forks source link

function "rand_rows" #19

Closed cslayers closed 6 years ago

cslayers commented 6 years ago

I am curious about the function rand_rows ,when it selecting enough number of random rows of groups of matching points to calculate an affine matrix by the function solve_system. Why it remove most of rows instead of picking serveral rows? Looking forward to your reply. Thanks you! image image

bbrister commented 6 years ago

Thanks for the find. This is actually a very old and sloppy part of the code. I think I will rewrite it in the next version.

A much better algorithm would be to get a list of random row indices using Knuth shuffles, then copy those rows into the output.

However, mathematically speaking, the existing implementation does indeed return a uniformly random subset of the rows. It does not, however, permute those rows in a random way--the order of the remaining row indices is strictly increasing.

I never bothered to improve this before, since this function is only used in the RANSAC procedure, which so far hasn't been contributing much to the overall execution time.

bbrister commented 6 years ago

Refactored in version 1.4.5