I am working with OpenCV and C++. I have a matrix X like this
Mat X = Mat::zeros(13,6,CV_32FC1);
and I want to update just a submatrix 4×3 of it, but I have doubts on how to access that matrix in an efficient way.
Mat mat43= Mat::eye(4,3,CV_32FC1); //this is a submatrix at position (4,4)
Do I need to change element by element?
One of the quickest ways is setting a header matrix pointing to the range of columns/rows you want to update, like this:
Now, you can copy your matrix to aux (but actually you will be copying it to X, because aux is just a pointer):
Thats it.