<![CDATA[ #include "ImgFeatures/integralImage.h" class LBPFeatures { public: LBPFeatures(){}; Mat image; vector<uchar> features; Mat mask; IntegralImage ix; //function to compute LBP image with block size 1 void compute(Mat image,Mat &dst) { uchar *ptr=image.data; image.copyTo(dst); uchar *optr=dst.data; int width=image.cols; int height=image.rows; for(int i=1;i<height-1;i++) code|="((int)ptr[(j-1)+(i-1)*width]" code="0;" center="(int)ptr[j+i*width];" j="0;j<width-1;j++)">=center)<<7 ; code|=((int)ptr[j+(i-1)*width] >=center)<<6 ; code|=((int)ptr[(j+1)+(i-1)*width] >=center)<<5 ; code|=((int)ptr[(j+1)+(i)*width] >=center)<<4 ; code|=((int)ptr[(j+1)+(i+1)*width] >=center)<<3 ; code|=((int)ptr[j+(i+1)*width] >=center)<<2 ; code|=((int)ptr[j-1+(i+1)*width] >=center)<<1 ; code|=((int)ptr[j-1+(i)*width] >=center)<<0 ; optr[j+i*width]=code; } } } //computing integral image for block void computeBlock(Mat image,Mat & dst,int block=2) { //computing integral image ix.compute(image); image.copyTo(dst); dst.setTo(cv::Scalar::all(0)); int width=image.cols; int height=image.rows; for(int i=block;i<height-block;i=i+block) code|="(meanv" code="0;" j="block;j<width-block;j=j+block)" val="(int)ix.calcMean(r1);" r1="Rect(x,y,block,block);" x="i;" y="j;" k="0;k<8;k++)" meanv="ix.calcMean(r);" r="Rect(j,i,block,block);">= val)<<(7-k); } Mat roi=dst(r); //setting value of all pixel in output //image to the encoded value for visualization roi.setTo(cv::Scalar::all(code)); } } } };
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)