图像处理(二)

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;
    }

 

posted @ 2018-03-10 23:47  andyalgorithm  阅读(81)  评论(0编辑  收藏  举报