作者andycho (andy)
看板MATLAB
标题[问题]关於标记後影像的处理
时间Thu Oct 24 06:41:53 2013
现在将一张影像做完标记後
想要找出标记影像中像素最多的三个区域
程式如下
[L,n]=bwlabel(imgs,8);
count=zeros(1,max(max(L)));
for i=1:size(L,1)
for j=1:size(L,2)
count(L(i,j))=count(L(i,j))+1;
end
end
sf=sortrows(count');
想请问各位前辈
为何for回圈中的count(L(i,j))=count(L(i,j))+1会一直跳错误
那要如何去修正呢?
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 175.180.77.22
1F:→ aada:错误讯息是? 10/24 08:10
2F:→ andycho:Attempted to access count(0) 10/24 16:15
3F:→ andycho:index must be a positive integer or logical 10/24 16:17
4F:→ andycho:以上两行便是我Command Window出现的错误讯息 10/24 16:18
5F:→ aada:L(i,j)有为0的吗y 10/24 17:08
6F:→ aada:因为count里面并没有位置0的数据 10/24 17:09
7F:→ aada:试试看: count(L(i,j)+1)=count(L(i,j)+1)+1 10/24 17:10
8F:→ andycho:照您的方法,count内有东西了 10/24 20:57
9F:→ andycho:但这次出现的错误是Attempted那行的count()内为count(22) 10/24 20:59
10F:→ andycho:怎麽样处理这个问题会比较好呢?改回圈size试过但没办法 10/24 21:01
11F:→ andycho:谢谢aada,上述问题已经解决 10/24 23:36
※ 编辑: andycho 来自: 175.180.77.22 (10/24 23:57)
12F:→ aada:不客气, 所以现在的问题都解决了? 10/25 07:58