File Exchange

image thumbnail

Dense 3D patch extraction from video (stride allowed)

version 1.3 (2 KB) by

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

0 Downloads

Updated

View License

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

Comments and Ratings (0)

Updates

1.3

Description updated.

1.2

Variable declaration problem fixed for Windows.

1.1

Add more description.

MATLAB Release
MATLAB 8.2 (R2013b)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video