v9.1.1
Menu

Simple BRIEF Descriptor

mediumPROFeature DescriptorsFeaturesCV: Feature Detection and Matching

Implement a simplified BRIEF (Binary Robust Independent Elementary Features) descriptor, a type of feature descriptor used in computer vision to describe the appearance of an image patch. This descriptor is essential for tasks like image matching and object recognition.

The BRIEF descriptor creates binary strings by comparing pixel intensities at predefined point pairs. This process involves computing a series of binary tests, where each test compares the intensity of two pixels. The result of each comparison is a single binary digit.

Here are the steps to compute the BRIEF descriptor:

  1. Select a set of predefined point pairs (pi,qi)(p_i, q_i).
  2. Compare the pixel intensities at each pair of points.
  3. Record the result of each comparison as a binary digit.
bi={1if I(pi)<I(qi)0otherwiseb_i = \begin{cases} 1 & \text{if } I(p_i) < I(q_i) \\ 0 & \text{otherwise} \end{cases}

This technique is widely used in image processing and object detection applications.

Example

Input
patch = 31×31 grayscale patch
pairs = [((15,10), (15,20)), ((10,15), (20,15)), ...]
Output
[1, 0, 1, 1, 0, ...]
Reasoning
  • Inputs: patch is a 31×3131 \times 31 grid of grayscale intensities around a keypoint; pairs is a list of point pairs (pi,qi)(p_i, q_i), each point written as (row, column). The sample patch isn't a concrete array, so the intensities below are illustrative.
  • Pair 0, p0=(15,10)p_0 = (15, 10) and q0=(15,20)q_0 = (15, 20): same row, columns 10 and 20. With I(p0)=100I(p_0) = 100 and I(q0)=150I(q_0) = 150, we have 100<150100 < 150, so b0=1b_0 = 1.
  • Pair 1, p1=(10,15)p_1 = (10, 15) and q1=(20,15)q_1 = (20, 15): same column, rows 10 and 20. With I(p1)=120I(p_1) = 120 and I(q1)=80I(q_1) = 80, the test 120<80120 < 80 fails, so b1=0b_1 = 0.
  • The remaining pairs give b2=1b_2 = 1, b3=1b_3 = 1, b4=0b_4 = 0 the same way, and the bits in pair order form [1, 0, 1, 1, 0, ...]: one bit per pair, so 256 pairs give a 256-bit descriptor.
  • Notice the test is strict: if I(pi)=I(qi)I(p_i) = I(q_i) the bit is 0, so a perfectly flat patch produces all zeros.

Constraints

  • patch: Image patch centered on keypoint (31×31)
  • pairs: List of ((y1,x1), (y2,x2)) point pairs, each point as (row, col)
  • Return: Binary descriptor as list of 0/1

Learn this in

More from CV: Feature Detection and Matching

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.