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? 回答1: I do not believe that there is any built-in way to do this. If you need it to be fast, it should be fairly simple to write your own mex-function