代码如下,图片格式应该是CV_8UC1
用uchar类型打印就会出现乱码
cout << gry_src.type() << endl;
for (int i = 0; i < gry_src.rows; i++)
{
for (int j = 0; j <gry_src.cols; j++)
{
cout << gry_src.at<uchar>(i, j) << ",";
}
cout << endl;
}
gry_src.at<uchar>(i, j) 返回得是什么数据类型呀?如果是对象,不能直接这么输出呀,除非已经为改类型定义了输出操作符。
cout << (int)gry_src.at<uchar>(i, j) << ",";
像你那样子输出的是ascii码,转成int输出就没问题了