explanation on a bwtraceboundary code
조회 수: 5 (최근 30일)
이전 댓글 표시
I have this code and I can't understand what does the 55 on the 4th row. Can anyone explain me?
if true
BW = imread('blobs.png');
imshow(BW);
s=size(BW);
*for row = 2:55:s(1)*
for col=1:s(2)
if BW(row,col),
break;
end
end
contour = bwtraceboundary(BW, [row, col], 'W', 8, 50,...
'counterclockwise');
if(~isempty(contour))
hold on;
plot(contour(:,2),contour(:,1),'g','LineWidth',2);
hold on;
plot(col, row,'gx','LineWidth',2);
else
hold on; plot(col, row,'rx','LineWidth',2);
end
end
end
댓글 수: 0
답변 (1개)
Christiaan
2015년 3월 23일
Dear Rafaela,
In your code an image is imported, with the size (s1) by (s2) pixels. The first value corresponds to the amount of horizontal pixels. The second value corresponds to the amount of vertical pixels.
In the first for loop, an array is generated, where 8 rows are selected (2, 25, 112 .. etc). In the second loop each column is selected (1, 2, 3, ...) . Therefore by nesting these for loops, a grid is generated, where a calculation can be performed, where the knots of these gridlines can be used for calculation.
In this MATLAB code, the if loop checks if the point on that knot is zero (white). I hope this has helped you.
As a hint: On this Mathworks website, a short tutorial can be found to trace an object in an binary image.
Kind regards, Christiaan
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!