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

Adjust the coordinates to the base octave #17

Closed mmkorb closed 6 years ago

mmkorb commented 7 years ago

The points are being drawn correctly, however in CSV the correction was missing. In file sift.c, replace the lines 3120 to 3130 with:

    // Write the keypoints 
    for (i = 0; i < num_rows; i++) {

            const Keypoint *const key = kp->buf + i;
            const Mat_rm *const R = &key->R;

            // Adjust the coordinates to the base octave
            const double coord_factor = pow(2.0, key->o);

            // Write the coordinates 
            SIFT3D_MAT_RM_GET(&mat, i, kp_x, double) = coord_factor * key->xd +1;
            SIFT3D_MAT_RM_GET(&mat, i, kp_y, double) = coord_factor * key->yd +1;
            SIFT3D_MAT_RM_GET(&mat, i, kp_z, double) = coord_factor * key->zd +1;
            SIFT3D_MAT_RM_GET(&mat, i, kp_s, double) = key->sd;
bbrister commented 6 years ago

Thanks for the catch! I'll work this in to the next release. The only minor issue is that I won't add 1 to each coordinate, since the program uses 0-indexed coordinates, where the first voxel in the image is (0,0,0).

bbrister commented 6 years ago

Fixed in version 1.4.5. To be consistent with the Matlab interface, I decided to add the octave index to the output, rather than scale the coordinates.