subscripted assignment dimension mismatch - Edge effect
Show older comments
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.

Accepted Answer
More Answers (1)
Walter Roberson
on 14 Oct 2015
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 Comments
Rdmato33
on 14 Oct 2015
Rdmato33
on 14 Oct 2015
Walter Roberson
on 14 Oct 2015
Ah yes, I did switch them. Should have been
svf( T(m):B(m), L(m):R(m) )
Categories
Find more on Read, Write, and Modify Image 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!