-2

誰かがこの C++ コードの行の意味を教えてくれたら、私は大歓迎です。それは何をしているのですか?

temp = ((uchar*) matimg.data + i)[j];

このコードブロックで

int rows =(int) height;
int cols =(int) width;
Mat matimg(img);

vector<vector<double> > vec1(rows, vector<double>(cols));
int k =1;
for (int i=0; i < rows; i++) {
    for (int j =0; j < cols; j++){
        unsigned char temp;
        temp = ((uchar*) matimg.data + i)[j];
        vec1[i][j] = (double) temp;
    }

}

PS 私は C++ は話せません。C# は話せます。

4

2 に答える 2

3

It's overlaying the 1D matimg.data array with a number of matimg.step-spaced 2D matrices, and then virtually indexing it at (j, k).

于 2013-05-26T05:05:48.670 に答える
0

それが役立つ場合は、この式を次のように書き換えることもできます。

((uchar*) matimg.data)[ i * matimg.step + j * matimg.elemSize() + k ]

元の定式化は、データ アクセスの意図に関してより明確ですが、この定式化は、C# の書き直しを行う方法を示すのにより明確です。

于 2013-05-26T06:04:10.193 に答える