Assume that we have a 3D array x, and we would like to split it into 2D slices then cut every slice into some small patches and get all patches in single list t. How to do this?
What I have done is to extract a 2D slice and then cut it into patches but how to do this with all slices in one shot. For example:
x = RandomInteger[{1, 10}, {8, 8, 8}]; (* x is an 8x8x8 array *)
y = x[[1, ;;, ;;]]; (* y is an 8x8 array *)
z = Partition[y, {2, 2}, {2, 2}]; (* z is a 4x4x2x2 array *)
t = Flatten[z, 1]; (* t is a 16x2x2 array *)
How to repeat this for all x $ (8\times8\times8) $ and get some vector t $ (128\times2\times2) $?
Thanks for help!
x[[1,;;,;;]]is a bit easier to read asx[[1,All,All]]but actually it is equivalent tox[[1]]. – Jason B. Oct 17 '18 at 01:43