index matrix
Hi,
In my code I need to create a matrix filled with all the possible pixel 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 than:
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++;
}
}
what is your purpose of creating such a matrix?
I need to use a warping algorithm. Given an image (the Mat mentioned above), each pixel has a depth value ( stored in another Mat). The algorithm takes a set of coordinates and warps them to new coordinates.
So for each row of this matrix, I shall calculate a new set of values.
I wish to parallelise this process. Hence why i have isolated it into a separate process.