Binary Image Edge Linking

5 ビュー (過去 30 日間)
Jes
Jes 2015 年 5 月 28 日
コメント済み: Image Analyst 2015 年 6 月 3 日
I have a binary image of 200 rows and 200 columns. I need to find the distance between two white (255) pixel along the row and column. If the distance is 3 , i need to fill the gap along row and column with ones. I tried something but it doesnt work well. Can anyone please help me ?
vess is the binary output.
[M N]=size(vess);
[x y]=find(vess);
points = [ x y];
[~,ii] = sort(points(:,1));
out = points(ii,:);
% for i=1:M
[M1 N1]=size(points);
% u=2;
for i=1:M1-1
C=[out(i,1),out(i,2);out(i+1,1),out(i+1,2)];
d = round(pdist(C,'euclidean'))
if d==3
p1=[out(i,1),out(i,2)];
p2=[out(i+1,1),out(i+1,2)];
if p1(1)==p2(1)
vess(p1(1),p1(2)+1:p2(2)+1)=1;
end
if p2(2)==p1(2)
vess(p1(1)+1,p1(1):p2(1)+1)=1;
end
end
end

採用された回答

Image Analyst
Image Analyst 2015 年 5 月 28 日
Yes, I can tell it wouldn't.
  1. First of all you need to find the endpoints of your lines/curves segments with bwmorph.
  2. Then you need to label the segments and get a list of all the points in the segment.
  3. Then you need to get a list of the distances from each endpoint to all other endpoints that are not in the same segment, and pick the endpoint with the smallest distance.
  4. If the distance is less than some specified allowable distance, you need to use imline() to burn a line into the binary image connecting those two endpoints.
  5. Repeat for every endpoint.
So that's the algorithm, though it could be made more sophisticated if you were to add criteria like saying the angle of the ends needs to be about the same angle, etc.. So, try to code it up and if you run into trouble, be SURE to attach your binary image of your skeletonized line/curve segments.
  13 件のコメント
Jes
Jes 2015 年 6 月 2 日
編集済み: Jes 2015 年 6 月 3 日
Could you please help me how to obtain the binary edge linked image (variable) in the above code? Thanks in Advance.
Image Analyst
Image Analyst 2015 年 6 月 3 日
That's the part I have not finished yet. But I'll tell you how to do it. You need to use imline() to burn a line into an image and then "OR" that into the main binary image. I'm attaching a demo for doing that, which you can incorporate into the demo I already gave you.

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

その他の回答 (0 件)

カテゴリ

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