Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

what is the purpose of cos_t/=hist_width in OpenCV SIFT

Hello fellows,

I am digging into the source code of the SIFT in OpenCV, and I encountered a few lines of code that I can't justify. In the calcSIFTDescriptor portion, this function takes the input "ori" and calculate its respectful cos and sin. as the 2 lines shown below:

float cos_t = cosf(ori*(float)(CV_PI/180));                                                                       
float sin_t = sinf(ori*(float)(CV_PI/180));

A few lines later the cos_t and sin_t are divided by "hist_width" without being used by the 2 lines indicated below:

cos_t /= hist_width;                                                                                          
sin_t /= hist_width;

Then this modified cos_t and sin_t is used for rotation.

        float c_rot = j * cos_t - i * sin_t;
        float r_rot = j * sin_t + i * cos_t;

I find it hard to understand why the source code update the cos_t and sin_t by dividing them by hist_width. Any help would be appreciated!

Cheers!

Hughes