MATLAB Answers

kalai vani

How to slipt an image into equal & non-overlapping 2*2 matrixes in matlab?

Asked by kalai vani
on 19 Jul 2013
This question is closed and may reopen in the future if edited.

Hi friends, I am in need to slipt the image into 2*2 blocks. i used mat2cell comment but later i am unable to access each element in a cell.. so plz provide me the coding to slip the image using for loop.. its urgent...

3 Answers

Answer by Iain
on 19 Jul 2013
Edited by Iain
on 19 Jul 2013

For a 128 by 128...

 for i = 1:2:127
  for j = 1:2:127
   split_2x2(:,:,(i+1)/2,(j+1)/2) = image(i+[0 1],j+[0 1]);

a_2x2 = split_2x2(:,:,4,6)


Answer by Jos (10584)
on 19 Jul 2013
Edited by Jos (10584)
on 19 Jul 2013

To access the contents of a cell you need to use curly braces

C = { magic(2) ; 3*magic(2)} ; 
C1 = C(1)
C2 = C{1}


Join the 15-year community celebration.

Play games and win prizes!

Learn more
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

MATLAB Academy

New to MATLAB?

Learn MATLAB today!