explanation on a bwtraceboundary code

1 回表示 (過去 30 日間)
rafaela nicolaou
rafaela nicolaou 2015 年 3 月 21 日
回答済み: Christiaan 2015 年 3 月 23 日
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

回答 (1 件)

Christiaan
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

カテゴリ

Help Center および File ExchangeImages についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by