We can see that as block size increases, quantization effects can be seen and the information in the encoded image cannot be recognized.
<![CDATA[
#include "ImgFeatures/integralImage.h"
class LBPFeatures
{
public: LBPFeatures(){};
Mat image;
vector<uchar> features;
Mat mask;
IntegralImage ix; 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;
}
}
} void computeBlock(Mat image,Mat & dst,int block=2)
{ 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); roi.setTo(cv::Scalar::all(code));
}
}
}
};