Binary Robust Independent Elementary Features
lastmod 2019-12-06created 2019-12-069 edits
About
BRIEF provides a fast way to obtain binary strings without needing to detect feature descriptors. Once BRIEF has produced binary strings for image descriptors, the descriptors are matched using the Hamming distance.
One important point is that BRIEF is a feature descriptor and does not provide any other way to detect image features. So for image feature detection, it must be used together with an image feature detection method such as SIFT or SURF.
In summary, BRIEF is a method for quickly computing and matching image feature descriptors.
Theory
We know that SIFT uses a 128-dimensional vector for its descriptor. Since it uses floating-point numbers, it takes 512 bytes. Similarly, SURF takes at least 256 bytes (for 64 dimensions). Creating thousands of feature vectors consumes a great deal of memory, which is not feasible when resources are limited, especially in embedded systems. The larger the memory, the longer matching takes.
But not all of these dimensions are needed for actual matching. We can compress them with various methods such as PCA and LDA. Hashing with LSH (Locally Sensitive Hashing) converts floating-point SIFT descriptors into binary strings. These binary strings are used to match features with the Hamming distance. Using the Hamming distance is just applying XOR and bit operations, so it can increase speed. But here we have to find the descriptors first and only then apply hashing, which does not solve the initial memory problem.
That is where BRIEF comes in. It provides a shortcut to find the binary strings directly without finding descriptors. It takes a smoothened image patch and selects a set of nd (x,y) location pairs in a unique way. Then some pixel intensity comparisons are made within these location pairs. For example, let the first location pair be p and q. If I(p)<I(q), the result is 1; otherwise it is 0. This is applied to all nd location pairs to get an nd-dimensional bitstring (a string of binary values made of 0s and 1s).
nd can be 128, 256 or 512. OpenCV supports all of these, but the default is 256. (OpenCV expresses it in bytes, so the values are 16, 32, 64.) Once you have this, you can match these descriptors using the Hamming distance.
One important point is that BRIEF is a feature descriptor but does not provide a way to find features. So you must use another feature detection method such as SIFT or SURF. The paper recommends using CenSurE, a fast detector, because BRIEF works even better with CenSurE points than with SURF points.
In summary, BRIEF is a faster method for feature descriptor computation and matching. It also provides a high recognition rate unless there is large in-plane rotation.
Example
The code below shows BRIEF description computation using the CenSurE detector. (The CenSurE detector is called the STAR detector in OpenCV.)
import numpy as np
import cv2
import matplotlib.pyplot as plt
img = cv2.imread('./images/irene.jpg')
img = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
img2 = None
# STAR 탐지기 먼저 개시
star = cv2.xfeatures2d.StarDetector_create()
# BRIEF 추출기 개시
brief = cv2.xfeatures2d.BriefDescriptorExtractor_create()
# STAR로 키포인트를 검출하고 BRIEF로 디스크립터 계산
kp1 = star.detect(img,None)
kp2,des = brief.compute(img,kp1)
img2 = cv2.drawKeypoints(img,kp1,img2,(255,0,0))
cv2.imshow('Result',img2)
cv2.waitKey()
cv2.destroyAllWindows()
See also
- Feature detection
- Features from accelerated segment test (FAST)
- Oriented FAST and rotated BRIEF (ORB)
Favorite site
- Fresh - Learning :: (OpenCV) 05-7. BRIEF (Binary Robust Independent Elementary Features)
- (Part 41) Fast computation of image descriptors - BRIEF : Naver Blog
- [Recommended] Data Science School - Image feature extraction 1
- [Recommended] Keypoint (image keypoint) and Descriptor (image descriptor): 1. Scale Space Representation of Image :: Modulabs tech blog 2