Multidimensional DCT with OpenCV

asked 2015-01-08 04:04:30 -0500

misha gravatar image

I have a 3D matrix (2 spatial dimensions, 1 temporal dimension). Its size is 32 x 32 x 64. I would like to calculate the 3D DCT of this matrix. The documentation hints that this may be possible:

DCT_ROWS performs a forward or inverse transform of every individual row of the input matrix. This flag enables you to transform multiple vectors simultaneously and can be used to decrease the overhead (which is sometimes several times larger than the processing itself) to perform 3D and higher-dimensional transforms and so forth.

But it doesn't go beyond that. How do I do a higher-dimensional DCT? I can think of a way of doing this by combining 1D DCTs (in one direction) and rotation (transposition?) of the 3D matrix, but I don't see an easy way to rotate the matrix. Can somebody point me in the right direction?

edit retag flag offensive close merge delete


can you allow to "flatten" (reshape) your 2d images to 1d ? (do you need the 2d-information?)

then it would be possible to arrange a Mat with 64 rows and 32x32 cols, and do a dct on that (using the mentioned DCT_ROWS flag).

berak gravatar imageberak ( 2015-01-08 07:38:43 -0500 )edit

I'm not sure, but I might be able to do that. Thank you for your suggestion.

misha gravatar imagemisha ( 2015-01-08 18:31:18 -0500 )edit