v9.1.1
Menu

Oriented BRIEF Descriptor

hardPROFeature Detection and MatchingComputer Vision 1

Compute an oriented BRIEF (Binary Robust Independent Elementary Features) descriptor from a binary image patch.

Given a 2D binary patch (grid of 0s and 1s), a list of point pairs for comparison, and a rotation angle θ\theta, compute a binary descriptor by:

  1. Rotate the sampling pattern by angle θ\theta: For each point pair [(r1,c1,r2,c2)][(r_1, c_1, r_2, c_2)], rotate both points around the patch center using: r′=cos⁡θ⋅(r−rc)−sin⁡θ⋅(c−cc)+rcr' = \cos\theta \cdot (r - r_c) - \sin\theta \cdot (c - c_c) + r_c c′=sin⁡θ⋅(r−rc)+cos⁡θ⋅(c−cc)+ccc' = \sin\theta \cdot (r - r_c) + \cos\theta \cdot (c - c_c) + c_c where (rc,cc)(r_c, c_c) is the patch center.

  2. Round rotated coordinates to nearest integer.

  3. Compare patch values: for each pair, output 1 if patch[r1′][c1′]<patch[r2′][c2′]\text{patch}[r_1'][c_1'] < \text{patch}[r_2'][c_2'], else 0.

  4. If rotated coordinates are out of bounds, treat the value as 0.

Return the binary descriptor as a list of 0s and 1s.

Example

Input
patch = [[0, 1, 0],
        [1, 0, 1],
        [0, 1, 0]]
pairs = [[0, 1, 1, 0], [1, 2, 2, 1]]
theta = 0.0
Output
[0, 0]
Reasoning
  • The patch center (rc,cc)(r_c, c_c) is calculated as the middle point of the patch, which is (1,1)(1, 1) since the patch is a 3×33 \times 3 grid.
  • The rotation angle θ=0.0\theta = 0.0 means no rotation is applied, so the point pairs remain the same: [(0,1,1,0),(1,2,2,1)][(0, 1, 1, 0), (1, 2, 2, 1)].
  • For each pair, we compare the patch values: for the first pair, patch[0][1]=1\text{patch}[0][1] = 1 and patch[1][0]=1\text{patch}[1][0] = 1, so the output is 00 since 1≮11 \not< 1; for the second pair, patch[1][2]=1\text{patch}[1][2] = 1 and patch[2][1]=1\text{patch}[2][1] = 1, so the output is 00 since 1≮11 \not< 1.
  • The final output is a list of these comparison results: [0,0][0, 0].

Constraints

  • patch: 2D list of 0s and 1s (square patch, odd size)
  • pairs: List of [r1, c1, r2, c2] tuples
  • theta: Rotation angle in radians
  • Return: List of 0s and 1s (binary descriptor)
  • Use math for cos/sin
  • Round rotated coordinates to nearest integer

More from Computer Vision 1

PRO

Editor locked

The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.

solution.py

Test results

Sign in to run your code against the test cases.