chain code for line

1 回表示 (過去 30 日間)
majed majed
majed majed 2015 年 11 月 5 日
コメント済み: majed majed 2015 年 11 月 7 日
here is my question : in this image which I have attached , starting from (x,y) or (s,t)how can I write the chain code for the line ? what is proper idea to write its code ? a lot of thank for everyone help me or try to help .

採用された回答

Walter Roberson
Walter Roberson 2015 年 11 月 6 日
  1 件のコメント
majed majed
majed majed 2015 年 11 月 7 日
Thank you to your answer, I have traied it , but I didn't get the gall.

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

その他の回答 (1 件)

Guillaume
Guillaume 2015 年 11 月 5 日
編集済み: Guillaume 2015 年 11 月 5 日
I've no idea what a chain code is, but if you're wanting to trace the path from (s,t) to (I,J) isn't it simply finding which of the eight neighbouring pixel is black, excluding pixels you've already been through.
currentrow = s;
currentcol = t;
path = [currentrow currentcol]
while currentrow ~= I && currentrow ~= J
[neighbours(:, 1), neighbours(:, 2)] = find(img(currentrow-1:currentrow+1, currentcol-1:currentcol+1) & [1 1 1;1 0 1;1 1 1])); %ignoring edge issues here
notvisited = ~ismember(neighbours, path, 'rows');
path = [path; neighbours(notvisited)]; %assumes there's only ever one non-visited neighbour
currentrow = neighbours(notvisited, 1);
currentcol = neighbours(notvisited, 2);
end
  1 件のコメント
majed majed
majed majed 2015 年 11 月 6 日
編集済み: majed majed 2015 年 11 月 6 日
Thank you a lot , in my question if I start from any edge ,I don't know where is the other edge , so when I find the starting point (one of the edges) ,I need to extract the angle between current pixel and next pixel according to freeman chaincode edea ,suppose that the pixels inside line has just tow neighbors. that's it exactly what I want, thanks

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

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by