opencv访问图像像素:
Mat image = imread("C:\\Users\\Administrator\\Desktop\\image.jpg"); ofstream out("log.txt"); int rows = image.rows; int cols = image.cols; for (int i = 0; i < rows; i++) { uchar* data = (uchar*)image.data + i*image.step[0]; for (int j = 0; j < cols; j++) { out << (int)data[j*3] << "," << (int)data[j*3+1] << "," << (int)data[3*j+2] << " "; } cout << endl; }