index exceeds matrix dimension

3 vues (au cours des 30 derniers jours)
sbei arafet
sbei arafet le 21 Mar 2016
Modifié(e) : Adam le 21 Mar 2016
Hi i tried this code but it says that index exceeds matrix dimensoin
fgx=fg(:,1);% Foreground or object pixels
fgy=fg(:,2);
for i = 1:size(fgx,1)
obj_pixels(i)=im(fgx(i),fgy(i));% Extract values of foreground pixels
end
sizes:
size(fgx)=10941x1
size(fgy)=10941x1
size(fgx,1)=10941
i=129
i don't know why i is stoped only on 129
thanks in advance
  1 commentaire
Adam
Adam le 21 Mar 2016
Modifié(e) : Adam le 21 Mar 2016
Without being able to run the code I suspect that the index that is exceeding the matrix dimension is not 'i' as an index to fgx or fgy, but the result of fgx(i) or fgy(i) exceeds the dimensions of 'im' when you try to index into it using these.
What is the size of 'im' and what are the values of fgx(129) and fgy(129)?

Connectez-vous pour commenter.

Réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by