I know how to divide my 256x256 image into 16x16 blocks using mat2cell. Now I want to access those 16x16 blocks successively to further divide them into 4x4 blocks.
4 ビュー (過去 30 日間)
古いコメントを表示
I'm able to do this further division by taking one 16x16 block at a time (first using cell2mat and then again using mat2cell this time with parameter 4), but I want to do it using some 'for' loop, or anything for that matter in which I wouldn't have to access each 16x16 blocks individually.
Any idea how I can achieve that?
Thank you.
0 件のコメント
採用された回答
Ameer Hamza
2020 年 10 月 20 日
編集済み: Ameer Hamza
2020 年 10 月 20 日
Read about cellfun(). Try something like this
img = rand(256);
C1 = mat2cell(img, 16*ones(16,1), 16*ones(16,1));
C2 = cellfun(@(x) mat2cell(x, 4*ones(4,1), 4*ones(4,1)), C1, 'UniformOutput', 0);
0 件のコメント
その他の回答 (1 件)
Matt J
2020 年 10 月 20 日
編集済み: Matt J
2020 年 10 月 20 日
Using mat2tiles
Image=rand(256);
ImageCell=mat2tiles(mat2tiles(Image,[4,4]),[4,4]);
>> ImageCell{2,3}
ans =
4×4 cell array
{4×4 double} {4×4 double} {4×4 double} {4×4 double}
{4×4 double} {4×4 double} {4×4 double} {4×4 double}
{4×4 double} {4×4 double} {4×4 double} {4×4 double}
{4×4 double} {4×4 double} {4×4 double} {4×4 double}
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Computer Vision with Simulink についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!