Documente Academic
Documente Profesional
Documente Cultură
Introduction ============ This is a class to calculate histogram of LBP (local binary patterns) from an input image, histograms of LBP-TOP (local binary patterns on three orthogonal planes) from an image sequence, histogram of the rotation invariant VLBP (volume local binary patterns) or uniform rotation invariant VLBP from an image sequence.
Reference ========= 1. Guoying Zhao, Matti Pietikinen, "Dynamic Texture Recognition Using Local Binary Patterns with an Application to Facial Expressions," IEEE Transactions on Pattern Analysis and Machine Intelligence, vol. 29, no. 6, pp. 915-928, June 2007, doi:10.1109/TPAMI.2007.1110 2. Guoying Zhao, Matti Pietikainen, "Dynamic texture recognition using volume local binary patterns," In: Dynamical Vision, WDW 2005/2006 Proceedings, Lecture Notes in Computer Science 4358, 2006, 165-177.
Change ====== * Some data structure are changed. * Add the calculation of histogram of uniform rotation invariant VLBP.
Availability ============ It is available at http://www.openpr.org.cn //a simple example of the usage of the LBP class
#include "../LBP.h"
tlength = 16; char** filename = new char*[tlength]; for(i=0; i<tlength; i++) { filename[i] = new char[MAX_LENGTH]; sprintf(filename[i], "%d.png", i); }
return -2; } width = pImg->width; height = pImg->height; printf("The size of the input image is: %d x %d\n\n", width, height);
//load image(s) and write the data into a 3d array for(i=0; i<tlength; i++) { //load image pImg = cvLoadImage(filename[i]); if(!pImg) { printf("Cannot load image.\n"); return -2; }
if(i>=1) { if((pImg->width!=width) || (pImg->height!=height)) { printf("All the images in the sequence must be of the same size!\n"); return -3;
} }
for(j=0; j<height; j++) { pppArray[i][j] = new uchar[width]; if(!pppArray[i][j]) { printf("Allocating memory failed.\n"); return -1; }
lbp.tlength = 1;
lbp.interp = 1;
lbp.CreateHistogram(pppArray, 0); printf("======== LBP ========\n"); printf("The histogram is:\n"); for(i=0; i<lbp.uni_bin.xy+1; i++) {
printf("%f ", lbp.uni_hist.pHist_xy[i]); } printf("\n"); printf("The bin number of uniform patterns is: %d\n", lbp.uni_bin.xy); printf("\n\n");
lbp.width = width;
lbp.height = height;
lbp.tlength = tlength;
lbp.CreateHistogram(pppArray, 1);
printf("======== LBP-TOP ========\n"); printf("The histogram of X-Y plane:\n"); for(i=0; i<lbp.uni_bin.xy+1; i++) { printf("%f ", lbp.uni_hist.pHist_xy[i]); } printf("\n"); printf("The histogram of X-T plane:\n"); for(i=0; i<lbp.uni_bin.xt+1; i++) { printf("%f ", lbp.uni_hist.pHist_xt[i]); } printf("\n"); printf("The histogram of Y-T plane:\n"); for(i=0; i<lbp.uni_bin.yt+1; i++) { printf("%f ", lbp.uni_hist.pHist_yt[i]); } printf("\n"); printf("The bin numbers of uniform patterns is: %d %d %d\n", lbp.uni_bin.xy, lbp.uni_bin.xt, lbp.uni_bin.yt); printf("\n\n");
lbp.height = height;
lbp.interp = 1;
lbp.norm = 1;
lbp.CreateHistogram(pppArray, 2, 1); //rilbp based histogram printf("======== RIVLBP ========\n"); int cnt=0; for(i=0; i<lbp.ri_bin; i++) { if(lbp.pHist_ri[i]) { cnt++; }
printf("%f ", lbp.pHist_ri[i]); } printf("\n"); printf("The bin number is: %d \n", lbp.ri_bin); printf("The number of non-zero rivlbp patterns is: %d ", cnt); printf("\n\n");
printf("======== uniform RIVLBP ========\n"); cnt=0; for(i=0; i<lbp.ri_bin; i++) { if(lbp.pHist_ri[i]) { cnt++; }
printf("%f ", lbp.pHist_ri[i]); } printf("\n"); printf("The bin number of uniform rivlbp is: %d \n", lbp.ri_bin); printf("The number of non-zero uniform rivlbp patterns is: %d ", cnt); printf("\n\n");
//release memory if(pppArray) { for(i=0; i<tlength; i++) { if(pppArray[i]) { for(j=0; j<height; j++) {
delete []pppArray[i]; } }
delete []pppArray; }
cvReleaseImage(&pImg); cvReleaseImage(&pGray);
return 0; }