How to connect two objects based on least distance between them?
1 次查看(过去 30 天)
显示 更早的评论
I have a binary image containing two separate objects...I want to connect them such that they are connected on basis where the distance between them is the least?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/151795/image.png)
0 个评论
采纳的回答
Image Analyst
2015-7-1
Call bwboundaries. Then have some for loops where you check all the boundary coordinates to see which distance is least. Then you can use imline() to burn a connecting line into the image, like in the attached demo.
7 个评论
更多回答(1 个)
Image Analyst
2015-7-3
peyush, your code didn't even seem to attempt to modify my code at all. It looks like I need to do it for you. See the attached demo which makes the connection.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/177604/image.jpeg)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Convert Image Type 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!