solve the code for label assigning
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (0)
Vedere anche
Categorie
Scopri di più su Matrix Indexing in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!