OpenCV Learning (III.) research on-LBP algorithm and its realization __ algorithm

Source: Internet
Author: User
first, the original LBP algorithm

The basic idea of LBP is to sum up the results of the pixels of the image and the pixels around it. This pixel is used as the center to compare the threshold values of adjacent pixels. If the center pixel's brightness is greater than or equal to his neighboring pixel, mark him as 1, otherwise mark it as 0. You will use binary numbers to denote each pixel, such as 11001111. Therefore, due to the surrounding 8 pixels, you may end up getting 2^8 a possible combination, called the local two-value pattern, sometimes called the LBP code. The first LBP operator described in the literature is actually using the neighborhood of 3*3.


A more formal LBP operation can be defined as


Which is the center pixel, the brightness is, and the brightness of the adjacent pixel. S is a symbolic function:

This description allows you to capture the details of the image in a good way. In fact, researchers can use it to get the most advanced level of texture classification. As the method described earlier is proposed, the fixed nearest neighbor region is invalid for the coding of the scale change. Therefore, the extension method of using a variable is described in the literature [AHP04]. The idea is to encode the neighboring pixels using a circle with a variable radius, so that you can capture the following nearest neighbor:

For a given point, his nearest neighbor can be computed as follows:


where r is the radius of the circle, and P is the number of sample points.

This operation is an extension of the original LBP operator, so it is sometimes referred to as an extended LBP (also known as a circular LBP). If a point on the circle is not in the image coordinates, we use his interpolation point. Computer science has a bunch of clever interpolation methods, and OpenCV uses bilinear interpolation.



Two. The realization of the original LBP algorithm

Attached code:

LBP.cpp: Defines the entry point for a console application. /*********************************************************************** * OpenCV 2.4.4 Test routine * Du Jianjian provides ************ /#include "stdafx.h" #include <opencv2/opencv.hpp
> #include <cv.h> #include  



three. Sample results, LBP texture features

Original Image Lena.jpg

After converting to a grayscale chart:


To extract the LBP features of a picture:



Extracting LBP features from human face images;



Four. Matters needing attention

12 functions can only be processed on the grayscale image, so, when using these two functions, you must first convert the original image to grayscale image before

2 solution to the problem of LBP texture features that show only the image 1/3 or 1/4 area earlier:

This is because your input image is not grayscale, it is necessary to convert the color map, multi-channel image into a single channel image, and then as the parameters of the function, to get the full image of LBP texture features.

3 Load Grayscale Image method:

The second parameter of the function Cvloadimage () function, and the second parameter of Imread (), is set to: Cv_load_image_anydepth | Cv_load_image_anycolor

It's OK. Oh also, this but I look for a long time on the internet to solve, share, welcome everyone a lot of guidance.
Five. The problems encountered
Is the use of mat structure to store color images, multi-channel image, how to convert it into a single channel of gray-scale map.
I found a lot of information on the Internet, did not find that there are related to reference functions can be directly invoked. There is a reference to using Iplimage and mat to transform each other. I would like to use this method, that is, first conversion and then call Cvcvtcolor () for the conversion of gray scale. But did not try, do not know can.
If a classmate knows how to do it, please let me know and appreciate it . 

Six. For reference

Facerec Documents in opencv2.4.4

http://blog.csdn.net/guoming0000/article/details/8022197

Wait a minute.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.