Access to 2D planes of a 3D matrix in OpenCV

I have a 3D matrix measuring 25 (rows) x 320 (cols) x 235 (channels)

For each of the 25 rows, I want to extract a 2D slice (320 x 235) so that I have 25 2D matrices.

I am not sure how to do this in OpenCV.

I was thinking about wrapping a three-dimensional matrix, so I have 320 (rows) x 235 (cols) x 25 (channels), and then use split to get 25 matrices, but transpose doesn't work (MATLAB doesn't even allow transposition on multidimensional arrays)

Then I tried to redo it to no avail.

Can i use NAryMatIterator? Or if there is any other way to complete this process?

+4
source share
1 answer

You can use the row () function to get a new heading for a given line, just call if on each line and save them. This is O (1) operation, because no data is copied, be careful that any changes you make will be reflected in the original matrix. There may be a more elegant solution, but I do not know about it. The rest depends on how you want to save your 25 matrices (in an array, vector, whatever). Mat documentation can be found here , although it is not very well structured.

+3
source

All Articles