#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/nonfree/features2d.hpp>
#include <opencv2/features2d/features2d.hpp>
using namespace std;
using namespace cv;
// 计算原始LBP特征
cv::Mat OLBP(cv::Mat& srcImage)
{
const int nRows = srcImage.rows;
const int nCols = srcImage.cols;
cv::Mat resultMat(srcImage.size(), srcImage.type());
// 遍历图像,生成LBP特征
for(int y = 1; y < nRows-1; y++)
{
for(int x = 1; x < nCols-1; x++)
{
// 定义邻域
uchar neighbor[8] = {0};
neighbor[0] = srcImage.at<uchar>(y-1, x-1);
neighbor[1] = srcImage.at<uchar>(y-1, x);
neighbor[2] = srcImage.at<uchar>(y-1, x+1);
neighbor[3] = srcImage.at<uchar>(y, x+1);
neighbor[4] = srcImage.at<uchar>(y+1, x+1);
neighbor[5] = srcImage.at<uchar>(y+1, x);
neighbor
opencv-计算原始LBP特征
最新推荐文章于 2022-03-25 23:37:42 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)