solve the code for label assigning

1 次查看(过去 30 天)
asthana
asthana 2014-4-3
hello this is the code for find the connectivity but still i didnt get the answer please tell me wats the wrong
Image=imread('rice.png'); [M, N]=size(Image); Connected = zeros(M,N); Mark = []; Offsets = [-1: M; 1: -M]; Index = []; No_of_Objects = 0;
for i= 1:M
for j= 1:N
if(Image(i,j)==1)
No_of_Objects = No_of_Objects +1;
Index = [((j-1)*M + i)];
Connected(Index)=Mark;
while ~isempty(Index)
Image(Index)=0;
Neighbors = bsxfun(@plus, Index, Offsets');
Neighbors = unique(Neighbors(:));
Index = Neighbors(find(Image(Neighbors)));
Connected(Index)=Mark;
end
Mark = Mark + Difference;
end
end
end

回答(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