question on smooth_histogram
poisonwine opened this issue · 3 comments
I want to know what smooth method does the following code use?
Thanks!
smooth_histogram[n] =(6 * raw_histogram[n] + 4 * (raw_histogram[n - 1] + raw_histogram[(n + 1) % num_bins]) + raw_histogram[n - 2] + raw_histogram[(n + 2) % num_bins]) / 16.
Hi @poisonwine ! Thanks a lot for your interest in this repo.
As explained in part 2 of my tutorial, that formula is the 5-point discrete Gaussian filter. The coefficients are the 5th row of Pascal's triangle. There is an in-depth derivation of this formula here, which is also linked to in my tutorial.
Hope this helps!
Thanks, I got it. And another question is why you use np.sqrt(sigma_total2- sigma_preveious2) to compute gaussian kernels, What's the benefit of doing this? I use k**(image_index) *sigma to compute, and the final performance also seems OK.
You're right, it's equivalent, and there's no significant performance difference. I only wrote it out this way to make it easy for people to follow along with the OpenCV implementation. I made this repo because when I was comparing the OpenCV implementation to the original SIFT paper, I saw that even though OpenCV implements every step faithfully, those steps are all jumbled around and difficult to follow. My python implementation is meant to be a bridge between the paper and OpenCV's implementation.
See line 208 here:
https://github.com/opencv/opencv/blob/master/modules/features2d/src/sift.dispatch.cpp