index exceeds matrix dimension

1 次查看(过去 30 天)
sbei arafet
sbei arafet 2016-3-21
编辑: Adam 2016-3-21
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 个评论
Adam
Adam 2016-3-21
编辑:Adam 2016-3-21
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)?

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by