Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

spliting image to 16x16 blocks

Asked by nadia naji on 4 Mar 2013

hi i have an image with size 320x240 i want to split it to 16x16 blocks but i don't use for loop. i don't process these blocks and i only save theme that after 30 frame i do LBP 3d on it? can you help me

0 Comments

nadia naji

Products

No products are associated with this question.

2 Answers

Answer by Jan Simon on 4 Mar 2013
SplitImage = reshape(Image, 16, 20, 16, 15);
SplitImage = permute(SplitImage, [1, 3, 2, 4]);
SplitImage = reshape(SplitImage, [16, 16, 300]);

0 Comments

Jan Simon
Answer by Walter Roberson on 4 Mar 2013
SplitImage = mat2cell(Image, 16 * ones(1, size(Image,1) / 16), 16 * ones(1, size(Image,2) / 16), size(Image,3));

3 Comments

Matt J on 4 Mar 2013

MAT2CELL does use a for-loop implicitly, though I suspect the OP is excessively concerned about loops.

Also, I'll just mention this file FEX:mat2tiles, which offers an easier interface.

 SplitImage=mat2tiles(Image,[16,16]);
nadia naji on 4 Mar 2013

thanks for your help i use this function

Matt J on 4 Mar 2013

Glad it does what you want, though if speed was your goal, Jan's method is about 4 times faster.

Walter Roberson

Contact us