Mat LBP(Mat src_image)
{
bool affiche=true;
cv::Mat Image(src_image.rows, src_image.cols, CV_8UC1);
cv::Mat lbp(src_image.rows, src_image.cols, CV_8UC1);
if (src_image.channels() == 3)
cvtColor(src_image, Image, CV_BGR2GRAY);
unsigned center = 0;
unsigned center_lbp = 0;
for (int row = 1; row < Image.rows-1; row++)
{
for (int col = 1; col < Image.cols-1; col++)
{
center = Image.at<uchar>(row, col);
center_lbp = 0;
if (center <= Image.at<uchar>(row - 1, col - 1))
center_lbp += 1;
if (center <= Image.at<uchar>(row - 1, col))
center_lbp += 2;
if (center <= Image.at<uchar>(row - 1, col + 1))
center_lbp += 4;
if (center <= Image.at<uchar>(row, col - 1))
center_lbp += 8;
if (center <= Image.at<uchar>(row, col + 1))
center_lbp += 16;
if (center <= Image.at<uchar>(row + 1, col - 1))
center_lbp += 32;
if (center <= Image.at<uchar>(row + 1, col))
center_lbp += 64;
if (center <= Image.at<uchar>(row + 1, col + 1))
center_lbp += 128;
lbp.at<uchar>(row, col) = center_lbp;
}
}
if(affiche == true)
{
cv::imshow("image LBP", lbp);
waitKey(10);
cv::imshow("grayscale",Image);
waitKey(10);
}
else
{
cv::destroyWindow("image LBP");
cv::destroyWindow("grayscale");
}
return lbp;
}
int main()
{
Mat frame1;
frame1= imread("path image")
LBP(frame1);
return 0;
}