Dense 3D patch extraction from video (stride allowed)
Similar to im2col, the video2col2 can extract columns of 3D patches from a 3D matrix, e.g. video. Spatial and temporal step sizes can also be applied.
Usage:
B=video2col2(A,[PATCH_SIZE], [STEP_SIZE]);
A: 3D matrix, e.g. a video.
PATCH_SIZE: size of a patch, e.g., [2,2,2].
STEP_SIZE: the stride in each dimension, e.g. [2,3,4].
The video2col2 will extract a floor[(M_r-w_r)/s_r+1] * floor[(M_c-w_c)/s_c+1] * floor[(M_t-w_t)/s_t+1] 3D patches B, where a video is of size M_r*M_c*M_t and each patch is of size w_r*w_c*w_t. The step size is [s_r, s_c, s_t] alone the spatial and temporal axis.
Each column in B is a patch.
Example:
A=rand(100,90,80);
B=video2col2(A,[3,4,5],[2,3,4]);
In this case, a video A is of size 100*90*80, i.e., the video has 80 frames and the number of rows is 100.
Patch size is 3*4*5 and the step size is 2*3*4. Then B will be a 60*26999 matrix, where 60 is the size of a patch (60=3*4*5) and 26999 is the number of extracted patches.
Tested on Mac and Windows with Matlab R2013b. You need to compile it using
mex -O video2col2.c
Cite As
Yu (2024). Dense 3D patch extraction from video (stride allowed) (https://www.mathworks.com/matlabcentral/fileexchange/45417-dense-3d-patch-extraction-from-video-stride-allowed), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.