Hi everyone, I've written my own LBP method however it does not work. The outputted histogram of codes is 1 column that is identical for every inputted image. However the LBP map looks correct, so I think there is an error with one of the inputs to calcHist(). Are there any obvious errors? Thanks.

```
Mat gray, lbpMap, hist;
lbpMap.create(in.rows-2, in.cols-2, CV_8UC1);
cvtColor(in, gray, CV_BGRA2GRAY);
for (int i = 1; i < in.rows-1; i++)
for (int j = 1; j < in.cols-1; j++){
uchar thisPixel = gray.at<uchar>(i,j);
uchar thisCode = 0;
if (thisPixel > gray.at<uchar>(i-1,j-1))
thisCode |= 1 << 7;
if (thisPixel > gray.at<uchar>(i,j-1))
thisCode |= 1 << 6;
if (thisPixel > gray.at<uchar>(i+1,j-1))
thisCode |= 1 << 5;
if (thisPixel > gray.at<uchar>(i,j-1))
thisCode |= 1 << 4;
if (thisPixel > gray.at<uchar>(i+1,j-1))
thisCode |= 1 << 3;
if (thisPixel > gray.at<uchar>(i-1,j+1))
thisCode |= 1 << 2;
if (thisPixel > gray.at<uchar>(i,j+1))
thisCode |= 1 << 1;
if (thisPixel > gray.at<uchar>(i+1,j+1))
thisCode += 1;
//Add this string to histogram
lbpMap.at<uchar>(i-1,j-1) = thisCode;
}
//After map built, get hist
const int channelNo[] = { 0 };
float range[] = { 0, 255 };
const float *ranges[] = { range };
int bins = 256;
calcHist(&lbpMap, 1, channelNo, Mat(), hist, 1, &bins, ranges);
```