参考:如何使用Opencv在C ++中获取特定行和列的像素值https://www.it1352.com/1134483.htmlhttps://www.it1352.com/1134483.html
图像中像素坐标和RGB值:
代码:
#include<opencv2/opencv.hpp>
#include<iostream>
using namespace std;
using namespace cv;
Mat src, gray, dst;
int main(int argc, char** argv)
{
src = imread("test.jpg");
if (src.empty())
{
printf("could not find image");
return -1;
}
namedWindow("input");
imshow("input", src);
Vec3b intensity = src.at<Vec3b>(150, 1800);//前面是Y坐标后面是X坐标就离谱
uchar blue = intensity.val[0];
printf("B: %d\n", blue);
uchar green = intensity.val[1];
printf("G: %d\n", green);
uchar red = intensity.val[2];
printf("R: %d\n", red);
waitKey(0);
return 0;
}