robwhess / opensift

Open-Source SIFT Library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Should it be consistent when calculating dx and dy in the function static int calc_grad_ori ?

icyhearts opened this issue · comments

Hi! I am reading your code. In the file sift.c, in function static int calc_grad_mag_ori( IplImage* img, int r, int c, double* mag,double* ori ):
when calculating dx, dx = pixval32f( img, r, c+1 ) - pixval32f( img, r, c-1 );
when calculating dy, dy = pixval32f( img, r-1, c ) - pixval32f( img, r+1, c );
I am wondering why not dy=pixval32f( img, r+1, c ) - pixval32f( img, r-1, c )?
In the column direction, bigger index minus smaller index;
however, in the row direction, smaller index minus bigger index.
Is the calculating of dx and dy consistent?

If I remember correctly, this was to match up with what was produced by Lowe's SIFT code. I think his gradients always went from top to bottom. Reversing the row coordinates as you suggested would have given gradients that went from bottom to top.

@robwhess OK. Thank you for your reply.