フィルターのクリア

How to resolve error from bwtraceboundary function

1 回表示 (過去 30 日間)
Issara Laosuwan
Issara Laosuwan 2016 年 6 月 9 日
コメント済み: Issara Laosuwan 2016 年 6 月 9 日
Hello! I tried using bwtraceboundary to trace the edge of object in a specific region.
im = imread('block.jpg');
im = rgb2gray(im);
BW = im2bw(im);
imshow(BW,[]);
r = 200;
c = 66;
contour = bwtraceboundary(BW,[r c],'W',8,Inf,'counterclockwise');
hold on;
plot(contour(:,2),contour(:,1),'g','LineWidth',2);
After I have computed, it return with error:
>> bwtrace
Index exceeds matrix dimensions.
Error in bwtrace (line 11)
plot(contour(:,2),contour(:,1),'g','LineWidth',2);
Please kindly help me on this issue.

採用された回答

Walter Roberson
Walter Roberson 2016 年 6 月 9 日
The starting location you provided, [r,c], does not happen to be part of any boundary.
  1 件のコメント
Issara Laosuwan
Issara Laosuwan 2016 年 6 月 9 日
Thank you very much! The code work fine now.

サインインしてコメントする。

その他の回答 (0 件)

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by