参考:
https://www.cnblogs.com/feifanrensheng/p/8947185.html
经典用法
Mat image;//申明Mat型数据
image.at<Vec3b>(i, j);//获取image位于(j,i)处的像素点
值得注意的是i、j分别对应图像数据的y(rows)与x(cols),与我们的常识相反。
测试代码:
//test
Mat img(3, 4, CV_8UC3);
for (int x = 0; x < img.cols; x++)
{
for (int y = 0; y < img.rows; y++)
{
Vec3b point;
point[0] = x;
point[1] = y;
point[2] = 0;
img.at<Vec3b>(y,x) = point;
}
}
cout << img << endl;
输出结果: