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!