Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Attempted to access pixels(0,1); index must be a positive integer or logical
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I'm trying to check the 3x3 neighbourhood for some pixel. For that, I did the following:
neighbour_F(1) = pixels(i-1,j-1);
neighbour_F(2) = pixels(i-1,j);
neighbour_F(3) = pixels(i-1,j+1);
neighbour_F(4) = pixels(i,j-1);
neighbour_F(6) = pixels(i,j+1);
neighbour_F(7) = pixels(i+1,j-1);
neighbour_F(8) = pixels(i+1,j);
neighbour_F(9) = pixels(i+1,j+1);
When I ran the code, I got the following error:
Attempted to access pixels(0,1); index must be a positive integer or logical.
Error in similarity (line 40)
neighbour_F(2) = pixels(i-1,j);
Yes, I know that this is since we will get a negative value for "i".
What can be done to avoid such error? I thought of adding if-statements, but, for instance, if I had to do "if i>1" twice (for two different neighbourhoods), will it just enter one of those if-blocks? As, I want to retrieve the value of all the neighbourhoods above.
Thanks.
0 comentarios
Respuestas (1)
Image Analyst
el 4 de Mzo. de 2014
There is no zeoreth row of a matrix. The first (top) row is number 1, not 0.
0 comentarios
La pregunta está cerrada.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!