3d patches from a 3d matrix
===

I have a 3d matrix `(3x3x3)`, and I need to extract 3d patches `(2x2x2)` and transform them in vectors.

In 2d, simply:

`I=randi(5,3,3);`

`2d_patches=im2col(I,[2 2],'sliding');`

What about 3d?

`I=randi(5,3,3,3);`

`3d_patches= ???`

im2col just works in 2d. In 3d I should recombine the vectors `1` and `7`, `2` and `8`, ...
Is there any fast function for this task?