PIXELBANKv9.1.0
Menu

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
πŸ”’

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

0/0
Run code to see test results.