Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to calculate Local Binary Pattern Histograms with OpenCV?

I have already seen that OpenCV provides a classifier based on LBP histograms:

But I want to have access to the LBP histogram itself. For instance:

histogram = calculate_LBP_Histogram( image )

Is there any function that performs this in OpenCV?

like image 768
EijiAdachi Avatar asked Dec 05 '12 22:12

EijiAdachi


People also ask

How do you calculate LBP?

For calculating the LBP, the LBP code for each pixel is calculated and the histogram of LBP codes is constructed as the LBP feature. To calculate the lbp code, for each pixel p, the 8 neighbours of the center pixel are compared with the pixel p and the neighbours x are assigned a value 1 if x ≥ p. Fig.

What is local binary pattern histogram?

LBPH (Local Binary Pattern Histogram) is a Face-Recognition algorithm it is used to recognize the face of a person. It is known for its performance and how it is able to recognize the face of a person from both front face and side face.

What is LBP in image processing?

Local Binary Pattern (LBP) is a simple yet very efficient texture operator which labels the pixels of an image by thresholding the neighborhood of each pixel and considers the result as a binary number.


1 Answers

You can get the C++ code for computing LBP using OpenCV's Mat data structure here:

http://www.bytefish.de/blog/local_binary_patterns

You should be able to find the Python version as well on the same site.

The code is written by Philipp Wagner, who I believe contributed the face recognition code you mentioned to OpenCV, so it should be the same thing.

The LBP code is found in the file: OpenCV-2.4.2/modules/contrib/src/facerec.cpp as a static function. Unfortunately, it does not appear to be exposed for public use (at least for OpenCV 2.4.2).

like image 172
lightalchemist Avatar answered Oct 07 '22 07:10

lightalchemist