Intersect() Problem when none of the pixels overlap

1 回表示 (過去 30 日間)
Hg
Hg 2016 年 1 月 28 日
コメント済み: Hg 2016 年 2 月 1 日
When I used intersect() to find the intersection between A (red) and B (blue), I failed to get any because the pixels don't overlap. What can I do to estimate the intersection point?
  2 件のコメント
Ashish Uthama
Ashish Uthama 2016 年 1 月 28 日
編集済み: Ashish Uthama 2016 年 1 月 28 日
How would you define (for a computer) an intersection? For example, what if they just 'touch'? (Image 1 and 2 represent A and B)
1 0 0 2
0 1 2 0
0 1 2 0
1 0 0 2
Hg
Hg 2016 年 1 月 29 日
In my case, the A (red) is a line so I can thicken or extend it to get an intersection.

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

採用された回答

Image Analyst
Image Analyst 2016 年 1 月 28 日
There is no one pixel where the overlap occurs. If you'll accept any of those 4 pixel locations as an overlap, then perhaps if you dilated, ANDed, then called bwulterode. Something like (untested)
intImage = imdilate(bw1, true(3)) & imdilate(bw2, true(3));
intPoints = bwulterode(intImage);
bwulterode() has some connectivity options, so you might play around with those.
  3 件のコメント
Image Analyst
Image Analyst 2016 年 1 月 29 日
編集済み: Image Analyst 2016 年 1 月 29 日
That's exactly what the first line of code does. It thickens the lines. Then I AND it to find the intersection. It sounds like you think your method is different somehow, but I think they're the same. What I do in my second line of code, to prevent getting an intersection point that is thicker, is to call bwulterode() which shrinks everything down to a single point.
Another thing you could try is to OR the two binary images together and then use bwmorph() to get branchpoints:
intPoints = bwmorph(bw1 | bw2, 'Branchpoints');
Hg
Hg 2016 年 2 月 1 日
Got it. It is exactly what I need. Thanks for the insight!

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by