question about command 'mat2cell'
显示 更早的评论
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 !
采纳的回答
更多回答(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)
类别
在 帮助中心 和 File Exchange 中查找有关 Image Arithmetic 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!