SIFT Descriptor Bin Assignment Simulation
The SIFT descriptor uses 8 orientation bins covering 45° each. Each gradient contributes to adjacent bins based on linear interpolation.
Given gradient magnitude M and orientation θ (0° ≤ θ < 360°), calculate contributions to the two nearest bins.
Bins: 0→0°, 1→45°, 2→90°, ..., 7→315°
Interpolation: If θ is between bin centers, split M proportionally.
Constraints:
- 0 ≤ M ≤ 255
- 0 ≤ θ < 360
- Bins are 0-7 (wrap around: after 7 comes 0)
Examples:
| Input | Output | |-------|--------| | M=10, θ=10 | 0:7.78, 1:2.22 | | M=10, θ=45 | 1:10.0 | | M=10, θ=340 | 0:2.22, 7:7.78 |
Example
magnitude=10, theta=10
0:7.22,7:2.78
-
Calculate which bin the orientation falls into:
-
Determine the position within the bin range:
-
Split the magnitude between the current bin and the next bin using linear interpolation: bin 0 gets and bin 1 gets
-
Apply wraparound for the sample output (bin 1 wraps to bin 7): 0:7.22, 7:2.78