Today, my senior friend gave me a source code for the Gbit/s feature written by my doctor. I searched some materials online and combined the code to get a rough idea.
Based on the size of adjacent pixels compared with the neighboring points in the middle, the original HSV feature is set to 1 or 0, and then the domain information of each pixel is integrated into the number of fields encoded. Then, histogram statistics are performed on the encoding of all pixels in a block to obtain the feature of the local code processing (LDA.
The round-shaped HSV feature uses a circular area to encode and sample the image around each pixel. The rest are the same as those of the original HSV feature.
Here is the figure, said more understand http://blog.csdn.net/dujian996099665/article/details/8886576
There is a problem here. If you sample on the circle, it will inevitably lead to the coordinates of some calculated sampling points not integers. In an image, the coordinates of each pixel must be integers.
As shown in: If the R is set to 1, and the eight pixels sampled are evenly distributed on the circle. Because the vertices marked in red are the pixels to be encoded, their coordinates are integers (x, y ). The coordinates of the green points must not be integers, so the pixel values of the points cannot be obtained from the image.
Of course, a simple method can be replaced by the value of the nearest vertex, but a better method is bilinear interpolation.
That is, a linear combination of four vertices and pixel values around the Green Point is used to represent the pixel values of the green "vertex" (which does not exist in the actual image.
That is, two linear interpolation to complete green point estimation.
A simple and clear explanation of bilinear interpolation: http://www.cnblogs.com/linkr/p/3630902.html
The Code is as follows, starting from messy...
void calcLBPH(IplImage *pImg, CvMat* pLBPH){int i,j,k,p;CvMat* pImg_mat = cvCreateMat(pImg->height,pImg->width,CV_32FC1);cvConvert(pImg,pImg_mat);CvMat * pLBP_mat = cvCreateMat(pImg->height-4,pImg->width-4,CV_32FC1);if(pImg->nChannels != 1)//图像必须为单通道{//AfxMessageBox("The channels of images must be 1!");}//LBP图像像素灰度值清零for(i=0; i<pLBP_mat->height; i++){for(j=0; j<pLBP_mat->width; j++){cvmSet(pLBP_mat, i, j, 0);}} int weight[8]; //八个周边像素的权值weight[0] = 1;for(i=1;i<8;i++) weight[i] = 2 * weight[i-1];//为每个像素计算LBP编码int height = pImg->height;int width = pImg->width;double temp[4][2] = {-chaZ,chaZ,-chaZ,-chaZ,chaZ,-chaZ,chaZ,chaZ};double temp_y[4] = {0},temp_x[4] = {0};int temp_Iy[4] = {0},temp_Ix[4] = {0};double dis_y[4] = {0},dis_x[4] = {0};double wei[4][4] = {0};double end[4] = {0};for(i=2,k=0; i
Round-domain KNN features