필터 지우기
필터 지우기

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