question about command 'mat2cell'
Show older comments
dear all, I have an problem in terms of mat2cell command...
What i already know is how to deal with specific numbers, say for instance, the code for dividing image I (size 128*128 ) into non-overlapping blocks (size 8*8) is as the following:
c = mat2cell( I, [8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8], ...
[8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8]);
But I really struggled with how to write the code when there is no specific numbers, for example, divide an image I (size 128*128) into non-overlapping blocks (size n*n) , and the total amount of blocks is 128*128/n*n...
Could anyone help..? thx a lot !
Accepted Answer
More Answers (1)
Use repmat to build your vector of tile heights or widths.
A = ones(8);
n = 2;
v = repmat(n, 1, 4) % You could compute the 4 for this line
C = mat2cell(A, v, v)
Categories
Find more on Image Arithmetic in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!