How to extract 'row' of element from a 3D mat ?

asked 2016-11-15 04:58:32 -0500

Nbb gravatar image

I have an array of 48 matrices, each of size 49 x 49. I can merge them to form a 3D cube of size 48 x 49 x 49. How can I extract a 'row' of elements along the 3rd dimension to form a vector of 48 elements? I have tried using a for loop but I was wondering if there is a more elegant way of doing it. The Mat.col or Mat.row function only applies in 2D

edit retag flag offensive close merge delete

Comments

Up till 4 dimensions deep there is the Vec3b and Vec4b elements, but they do not work for 48 channels deep so I am afraid a for loop is what you need.

StevenPuttemans gravatar imageStevenPuttemans ( 2016-11-15 06:12:49 -0500 )edit
1

@StevenPuttemans - not true. you can have up to 255 channels (and use CV_8UC(255) and typedef your own Vec255b)

but the problem is rather: there is no such thing as a row in a 3d volume

berak gravatar imageberak ( 2016-11-15 09:18:23 -0500 )edit

He means a pixel through all 48 dimensions, which can be seen as a row right. Then creating that Vec255b is exactly what he is looking for!

StevenPuttemans gravatar imageStevenPuttemans ( 2016-11-15 09:23:17 -0500 )edit
1

idk. @Nbb, maybe you should tell us, how you mean it, or what it would be used for ;)

berak gravatar imageberak ( 2016-11-15 09:28:19 -0500 )edit