subscripted assignment dimension mismatch - Edge effect
Mostrar comentarios más antiguos
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.

Respuesta aceptada
Más respuestas (1)
Walter Roberson
el 14 de Oct. de 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 comentarios
Rdmato33
el 14 de Oct. de 2015
Rdmato33
el 14 de Oct. de 2015
Walter Roberson
el 14 de Oct. de 2015
Ah yes, I did switch them. Should have been
svf( T(m):B(m), L(m):R(m) )
Categorías
Más información sobre Read, Write, and Modify Image en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!