In the section on LBP, we have already developed the code for computing the LBP code for each pixel, given the input image, and have also seen some basic operations to detect uniform pattern bit vectors. We are now going to focus specifically on building a spatially enhanced histogram.
The following function constructs the uniform pattern histogram of a sub-image given to it as input. Instead of completely ignoring the non-uniform patterns from our analysis, we instead group them together into a single bin towards the end:
Mat uniformPatternHistogram(const Mat& src, int numPatterns) { Mat hist; hist = Mat::zeros(1, (numPatterns + 1), CV_32SC1); for(int i = 0; i < numPatterns; ++i) { if(countTransitions(convertToBinary(i)) > 2) hist.at<int>(0, i) = -1; } for(int i = 0; i < src.rows; i++) { for(int j = 0; j < src.cols; j++) { ...