Doubt in Region_Growing
조회 수: 2 (최근 30일)
이전 댓글 표시
Coding r:
for i=1:M
for j=1:N
if Y(i,j)==1
if (i-1)>0 & (i+1)<(M+1) & (j-1)>0 & (j+1)<(N+1)
for u= -1:1
for v= -1:1
if Y(i+u,j+v)==0 & abs(I(i+u,j+v)-seed)=threshold&1/(1+1/15*abs(I(i+u,j+v)-seed))>0.8 %%Error in this line.
Y(i+u,j+v)=1;
count=count+1;
s=s+I(i+u,j+v);
end
end
end
end
end
end
end
suit=suit+count;
sum=sum+s;
seed=sum/suit;
end
I intimate the line of error in coding I can't able to rectify the problem.I am try to work region_growing with MRI Image.Please rectify and reply me back.
댓글 수: 0
채택된 답변
Bård Skaflestad
2012년 1월 26일
This is very hard to read. Please consider marking up (and indenting) your code more properly the next time. I suggest using the "{} Code" button. Then it would look (something) like this
for i=1:M
for j=1:N
if Y(i,j)==1
if (i-1)>0 & (i+1)<(M+1) & (j-1)>0 & (j+1)<(N+1)
for u= -1:1
for v= -1:1
if Y(i+u,j+v)==0 & abs(I(i+u,j+v)-seed)=threshold&1/(1+1/15*abs(I(i+u,j+v)-seed))>0.8 %%Error in this line.
Y(i+u,j+v)=1;
count=count+1;
s=s+I(i+u,j+v);
end
end
end
end
end
end
end
suit=suit+count; sum=sum+s; seed=sum/suit;
end
The immediate problem is that you're using assignment (i.e., =) in the abs test versus threshold in the line you highlighted. You (probably) intended to use equality (i.e., ==) in stead.
There also appears to be a spurious end following the suit, sum and seed assignments. At least the final end does not match any of the |for|s or |if|s. Is it perhaps part of a larger loop or function body?
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!