Mat colorReduce0(cv::Mat &image, int div = 64)
{
int nr = image.rows; // number of rows
int nc = image.cols * image.channels(); // total number of elements per line
for (int j = 0; j
uchar* data = image.ptr(j);
for (int i = 0; i<nc; i++) {
cout << (int)data[j] << " ";
data[i] = data[i] / div*div + div / 2;
}
}
return image;
}
利用ptr操作时,cout << data[j]输出的是乱码,必须加上(int)强制转换才可以,有大腿解释一下吗?