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)
med-sweng
med-sweng el 4 de Mzo. de 2014
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
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.

Respuestas (1)

Image Analyst
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.

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by