Ask Your Question

Revision history [back]

HEP-histogram of equivalent patterns

There are a lot of papers comparing Local Binary Pattern (LBP) versus Local Ternary Pattern (LTP), or modifications to the original LBP operator like Center-symmetric local binary patterns (CS-LBP), Local quinary patterns (LQP), Completed Local Binary Pattern (CLBP) and so on.

All this methods belong to the same type and a framework for texture analysis can be build. This framework for texture analysis is called HEP (histogram of equivalent patterns) and it is described in this paper: Texture description through histograms of equivalent patterns

This is the project web page, with Matlab implementation of hep (hep.m):

http://dismac.dii.unipg.it/hep/index.html

It would be fantastic if Opencv had HEP implementation.







I have written some lines of pseudo-code assuming there is an Opencv implementation:

//create a hep descriptor. In this case, a uniform local binary pattern descriptor for gray-scale images 
int neighbors = 8;
int radius = 1;
//char is for    values between 0...255 (gray images)
HEP<LBP<u2>,char> * hep_lbp_u2_descriptor = new HEP<LBP<u2>>(neighbors,radius,..); 

//load a gray-scale image to test the descriptors
Mat image = imread(...., );

Mat gray_image;
cvtColor( image, gray_image, CV_BGR2GRAY );

 //1. First, you could have the possibility to test a "raw pattern" in order to 
 //see how this descriptor works for a given pixel

 Mat image_test = Mat::zeros(Size(3, 3), CV_8UC1);
 image_test.at<uchar>(0,0) = 1;
 image_test.at<uchar>(0,1) = 2;
 image_test.at<uchar>(0,2) = 3;
 image_test.at<uchar>(1,0) = 4;
 image_test.at<uchar>(1,1) = 4;
 image_test.at<uchar>(1,2) = 6;
 image_test.at<uchar>(2,0) = 7;
 image_test.at<uchar>(2,1) = 8;
 image_test.at<uchar>(2,2) = 9;

 //compute the "raw pattern" for the central pixel (1,1)
 cout<<"the value for the central pixel is"<<hep_lbp_u2_descriptor->compute_raw_pattern(image_test,1,1)<<endl;

 //2. You could use this descriptor to build a lbp-image (a hep-image):
 Mat lbp_image;
 hep_lbp_u2_descriptor->compute_map(gray_image,lbp_image);

 //3. You could have the posibility to build the lbp-histogram (a hep-histogram):
 Mat lbp_histogram;
 int width_divisions = 5;
 int height_divisions = 6;
 hep_lbp_u2_descriptor->compute_histogram_grid(gray_image, lbp_histogram, width_divisions ,height_divisions );
 //(in this case the lbp_histogram would have 59*5*6 features 
 //(uniform lbp with a neighborhood of 8 pixels))