subscripted assignment dimension mismatch - Edge effect
古いコメントを表示
Hello, I am trying to create 92 samples of 5x5 cells from an image. Problem : the loop is stopped by this message : subscripted assignment dimension mismatch. This is due to the edge effect (see below). How can I launch the loop without problem? How can I adapt the matrix size located to the edge?
This is my code :
for m=1:92
a(:,:,m) = svf(xy_points(m,1)-2:xy_points(m,1) + 2, xy_points(m,2)-2:xy_points(m,2)+2);
end
Thanks.

採用された回答
その他の回答 (1 件)
Walter Roberson
2015 年 10 月 14 日
L = max(1, xy_points(:,1)-2);
R = min(xy_points(:,1)+2, size(svf,2));
T = max(1, x_points(:,2)-2);
B = min(xy_points(:,2)+2, size(svf, 1));
for m=1:92
a{m} = svf( L(m):R(m), T(m):B(m) );
end
A cell array has to be used because the cells can end up different sizes due to the clipping against the boundaries.
3 件のコメント
Rdmato33
2015 年 10 月 14 日
Rdmato33
2015 年 10 月 14 日
Walter Roberson
2015 年 10 月 14 日
Ah yes, I did switch them. Should have been
svf( T(m):B(m), L(m):R(m) )
カテゴリ
ヘルプ センター および File Exchange で Read, Write, and Modify Image についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!