Hi,
In my code I need create a matrix filled with all the coordinates of an image Mat.
ex.for a 1024x768 image: [ 0, 0] [ 0, 1] [ 0, 2] . . . [1024, 768]
Is there a more efficient way of doing this then:
void indexMatrix(Mat &matrix, int height, int width){
int cols = height*width;
int index = 0;
matrix = Mat::ones(cols, 2, CV_8UC1);
for( int col = 0; col < width; ++col ) {
for (int row = 0; row < height; ++row) {
matrix.at<uchar>(index,0) = col;
matrix.at<uchar>(index,1) = row;
index++;
}
}