Code covered by the BSD License  

Be the first to rate this file! 5 Downloads (last 30 days) File Size: 2 KB File ID: #45417

Dense 3D patch extraction from video (stride allowed)


Yu (view profile)


06 Feb 2014 (Updated )

The code can extract columns of 3D patches from a 3D matrix (i.e. video). Stride is supported.

| Watch this File

File Information

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.
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.


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

Required Products MATLAB
MATLAB release MATLAB 8.2 (R2013b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
07 Feb 2014

Add more description.

26 Feb 2014

Variable declaration problem fixed for Windows.

26 Feb 2014

Description updated.

Contact us