【发布时间】:2012-05-05 04:50:22
【问题描述】:
我正在使用 cv::imread 加载图像并对该图像进行一些处理, 但我不知道为什么我不能从 imread 函数中读取返回的 Mat 的值。 我使用了 Mat.at 方法:
Mat iplimage = imread("Photo.jpg",1); //input
for(int i=0;i<iplimage.rows;i++){
for(int j=0;j<iplimage.cols;j++){
cout<<(int)iplimage.at<int>(i,j)<<" ";
}
cout<<endl;
}
但是出现了错误:
OpenCV 错误:断言失败 ( dims ::channels) > ((DataType<_tp>::depth) & ((1
但是如果我使用直接访问的方式就可以了:
Mat iplimage = imread("Photo.jpg",1); //input
for(int i=0;i<iplimage.rows;i++){
for(int j=0;j<iplimage.cols;j++){
cout<<(int)iplimage.data[i*iplimage.cols + j]<<" ";
}
cout<<endl;
}
谁能告诉我如何使用 Mat.at 方法访问上述 Mat? 感谢您的帮助!
【问题讨论】: