Filter löschen
Filter löschen

solve the code for label assigning

1 Ansicht (letzte 30 Tage)
asthana
asthana am 3 Apr. 2014
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

Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by